简体   繁体   English

如何使iPhone像Android中的登录屏幕

[英]How to make iphone like login screen in android

i need to create a login screen in android that will look like this. 我需要在android中创建一个如下所示的登录屏幕。 在此处输入图片说明

I have white rectangle image but that image is bigger than screen. 我有白色矩形图像,但该图像大于屏幕。 So whenever i am applying that image to linearlayout(that has edittext and button).linearlayout fills complete screen. 所以每当我将该图像应用于linearlayout(具有edittext和button).linearlayout就会填满整个屏幕。

I know its a very beginner question but how can i make this screen? 我知道这是一个非常初学者的问题,但是如何制作此屏幕? and i also want that that white image should work on every 而且我还希望该白色图像可以在每个

You need to create some drawables (XML), 1 for the background (so you can add the round corners) and another 1 for the button where you will add the gradient and stroke. 您需要创建一些可绘制对象(XML),其中1个用于背景(因此您可以添加圆角),另外一个1个用于按钮,您将在其中添加渐变和笔触。

EDIT: Added an example. 编辑:添加了一个示例。

Result: 结果:

结果图像

Layout.xml Layout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#d4d4d4" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="4dp"
        android:layout_marginRight="4dp"
        android:layout_marginTop="15dp"
        android:background="@drawable/round_borders"
        android:orientation="vertical"
        android:paddingTop="40dp" >

        <EditText
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:paddingBottom="0dp"
            android:paddingTop="0dp"
            android:singleLine="true"
            android:text="username" />

        <EditText
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:paddingBottom="0dp"
            android:paddingTop="0dp"
            android:singleLine="true"
            android:text="password" />

        <Button
            style="@style/OrangeButtons"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="40dp"
            android:gravity="center"
            android:paddingBottom="3dp"
            android:paddingTop="3dp"
            android:text="Log in" />
    </LinearLayout>
</RelativeLayout>

@style/OrangeButtons @ style / OrangeButtons

<style name="OrangeButtons">
    <item name="android:gravity">center</item>
    <item name="android:textColor">#FFFFFF</item>
    <item name="android:focusable">true</item>
    <item name="android:background">@drawable/orange_button</item>
</style>

@drawable/orange_button @ drawable / orange_button

<?xml version="1.0" encoding="utf-8"?>
<selector
    xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_pressed="true" >
        <shape>
            <gradient
                android:startColor="#f29d00"
                android:endColor="#d96c00"
                android:angle="270" />
            <stroke
                android:width="1dp"
                android:color="#fade96" />
            <corners
                android:radius="15dp" />
            <padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" />
        </shape>
    </item>

    <item android:state_focused="true" >
        <shape>
            <gradient
                android:endColor="#f29d00"
                android:startColor="#d96c00"
                android:angle="270" />
            <stroke
                android:width="1dp"
                android:color="#fade96" />
            <corners
                android:radius="15dp" />
            <padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" />
        </shape>
    </item>

    <item>        
        <shape>
            <gradient
                android:endColor="#f29d00"
                android:startColor="#d96c00"
                android:angle="90" />
            <stroke
                android:width="1dp"
                android:color="#fade96" />
            <corners
                android:radius="15dp" />
            <padding
                android:left="10dp"
                android:top="10dp"
                android:right="10dp"
                android:bottom="10dp" />
        </shape>
    </item>
</selector>

@drawable/round_borders @ drawable / round_borders

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="@android:color/white" />
    <padding android:left="20dp" android:top="35dp"
            android:right="20dp" android:bottom="15dp" />
    <corners android:radius="8dp" />
</shape>

You can set layout background to white `android:background="#FFFFFFFF" or something like that. 您可以将布局背景设置为白色`android:background =“#FFFFFFFF”或类似的东西。 You can also have a look at shape drawables http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape , use something like solid in your xml 您还可以查看形状可绘制对象http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape ,在xml中使用诸如solid之类的东西

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何在 Android 中制作动态翻转屏幕(如 iPhone 的) - How can i make a dynamic flipping screen(like that of iPhone) in Android 如何在Android中使Listview像iPhone Tableview一样? - How can I make Listview in android like iPhone Tableview? Android:开发像Facebook这样的登录屏幕 - Android: Developing a login screen like Facebook 如何在Android上使底部栏[或iPhone等导航栏]像myTubo? - How to make Bottom Bar [or Navigation Bar like iPhone] like myTubo on Android? 在Android和iPhone上键入时,登录屏幕上推 - Login screen push up while typing on android and iphone Android:如何制作Android活动的翻转动画,就像iphone从左到右水平翻转? - Android: How to make the flip animation for android activity, as like iphone flip horizontal from left to right? Android设置启动画面(活动)就像Iphone Part2一样 - Android Setting Up Splash Screen(Activity) Like Iphone Part2 Android设置启动画面(活动)就像Iphone Part1 - Android Setting Up Splash Screen(Activity) Like Iphone Part1 在Android中单击EditText时如何使背景增加(例如android中的Facebook登录) - How to make background push up when click EditText in android (like facebook login in android) 如何使用 XML 制作双渐变(类似iphone) - How to make a double gradient with XML (iphone like)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM