看看React Native Elements UI工具包

React Native Elements is a styling library with pre-built components to replace the basic, limited React Native components. It’s similar to Bootstrap, giving you useable styles that are broad enough to customize as your own. Every one of the components in React Native Elements is wrapped with the basic React Native component with styling based on the props you indicate.

React Native Elements是带有预构建组件的样式库,用于替换基本的有限React Native组件 。 它与Bootstrap相似,为您提供了可用的样式,这些样式足够广泛,可以根据您的需要进行自定义。 React Native Elements中的每个组件都包装有基本的React Native 组件,该组件具有根据您指定的道具进行样式设置的样式。

Throughout this article, we’ll abbreviate React Native Elements as RNE. We’ll go through the basics so you can understand how to use other components from RNE not discussed. But before we get there, let’s look at the basic installation.

在本文中,我们将React Native Elements简称为RNE。 我们将讲解基础知识,以便您了解如何使用RNE中未讨论的其他组件。 但是在到达那里之前,让我们看一下基本安装。

安装 (Installation)

$ npm i react-native-elements
// or
$ yarn add react-native-elements

If you’re not using Expo but the basic React Native CLI, you’ll need to install react-native-vector-icons. You will likely need to link as well by running: react-native link react-native-vector-icons.

如果您不是使用Expo而是使用基本的React Native CLI,则需要安装react-native-vector-icons 。 您可能还需要通过运行以下命令进行链接: react-native link react-native-vector-icons

Now that we have the library installed, it’s ready to use, and we can import any component from it like this: import { Icon } from 'react-native-elements';

现在我们已经安装了库,可以使用它了,我们可以从中导入任何组件,例如: import { Icon } from 'react-native-elements';

文本元素以及为什么要响应本机元素? (Text Element and Why React Native Elements?)

The primary purpose of React Native Elements is building on top of the basic React Native components to give you more flexibility and ease to theme your entire app. If you’ve ever written CSS for an entire app, you have probably found ways to save yourself some time and write things once instead of over and over. Can someone say “DRY”? Using RNE is perfect for this, as it is already written into the pre-built components, and you just need to use the same props.

React Native Elements的主要目的是在基本的React Native组件的基础上构建,从而为您提供更大的灵活性,并更轻松地为整个应用程序设置主题。 如果您曾经为整个应用程序编写过CSS,那么您可能已经找到了节省时间的方法,而不必一次又一次地编写东西。 有人可以说“干”吗? 为此,使用RNE非常完美,因为它已被写入到预先构建的组件中,而您只需要使用相同的道具即可。

The RNE component is a perfect example of this. It is the basic component from React Native, but with more props to style with. It has font-sizes pre-configured, which you can tap into, using either h1, h2, h3, or h4. The corresponding font sizes are 40, 34, 28, and 22. On top of that, there’s a prop for each heading size, like h1Style, h2Style, and so on. These apply to the container around the text. Look at the following example:

RNE 组件就是一个很好的例子。 它是React Native的基本组件,但还有更多样式支持。 它具有预先配置的字体大小,您可以使用h1h2h3h4 。 相应的字体大小为h1Style和22。最重要的是,每个标题大小都有一个支持,例如h1Styleh2Style等等。 这些适用于文本周围的容器。 看下面的例子:

Your Heading

Now we know our heading has a font-size of 34. That h2 is all we need and we can be sure all of our primary headings are the same size across our entire app. And the h2Style is for the container around it, if for any reason you wish to style the container. Of course, there are other ways to make it even more customizable to your own needs, but as you can see here, it’s easy to create a theme with the pre-built RNE components.

现在我们知道标题的字体大小为h2是我们所需要的,并且我们可以确保所有主要标题在整个应用程序中都相同。 如果您出于某种原因希望对容器进行样式设置,则h2Style用于其周围的容器。 当然,还有其他方法可以使它更加个性化,以满足您自己的需要,但是正如您在此处看到的那样,使用预构建的RNE组件创建主题很容易。

实施按钮元素 (Implement Button Element)

As discussed above, every component from RNE is already wrapped in a (that’s the container styled by h2style in the component above). What that means, is you can get away from manually wrapping all your components with a and instead you simply need to style the component with its prop: containerStyle. Take this example for instance:

如上所述,RNE中的每个组件都已经包装在 (这是上面组件中h2style样式的容器)。 这意味着您可以摆脱使用手动包装所有组件的 ,而只需要使用prop: containerStyle设置组件的样式即可。 以这个例子为例:

import { Button } from 'react-native-elements';
import { SafeAreaView } from 'react-native';

const App = () => (
  
    

What’s going on here? The component inside the RNE

你可能感兴趣的:(python,java,android,html,js,ViewUI)