如何设置在每个控制角落交叉并设置margin和padding在android系统 [英] how to set cross in each control corner and set margin and padding in android

查看:129
本文介绍了如何设置在每个控制角落交叉并设置margin和padding在android系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg03" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_margin="10dp"
        android:background="@android:color/transparent"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/layout1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="10dp"
            android:background="@drawable/gradient_bg_hover"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="139dp"
                android:layout_height="match_parent"
                android:text="Country"
                android:textColor="#a9a9a9"
                android:textSize="50px" />

            <Spinner
                android:id="@+id/spinner1"
                android:layout_width="wrap_content"
                android:layout_height="49dp" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/layout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:background="@drawable/gradient_bg_hover"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/editText1"
                android:layout_width="94dp"
                android:layout_height="wrap_content"
                android:ems="10"
                android:inputType="number"
                android:text="Code"
                android:textColor="#a9a9a9" >

                <requestFocus />
            </TextView>

            <EditText
                android:id="@+id/editText2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ems="10"
                android:inputType="phone"
                android:text="Phone"
                android:textColor="#a9a9a9" />
        </LinearLayout>

        <Button
            android:id="@+id/button1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:background="@drawable/buttonshape"
            android:text="Next"
            android:textColor="#0066FF"
            android:textStyle="bold" />
    </LinearLayout>

</RelativeLayout>

当前结果预期的效果

推荐答案

尝试下面code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg03" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_margin="10dp"
        android:background="@android:color/transparent"
        android:orientation="vertical" >

        <!-- <LinearLayout -->
        <!-- android:id="@+id/layout1" -->
        <!-- android:layout_width="wrap_content" -->
        <!-- android:layout_height="wrap_content" -->
        <!-- android:orientation="horizontal" > -->


        <!-- <TextView -->
        <!-- android:id="@+id/textView1" -->
        <!-- android:layout_width="139dp" -->
        <!-- android:layout_height="match_parent" -->
        <!-- android:text="Country" -->
        <!-- android:textColor="#a9a9a9" -->
        <!-- android:textSize="50px" /> -->

        <Spinner
            android:id="@+id/spinner1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:entries="@array/colors"
            android:background="@drawable/round_bg" //Set the dropdown image as background
            android:spinnerMode="dropdown" />

        <!-- </LinearLayout> -->

        <LinearLayout
            android:id="@+id/layout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:background="@drawable/selctor"
            android:orientation="horizontal"
            android:weightSum="1" >

            <EditText
                android:id="@+id/editText1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="5dp"
                android:layout_weight=".80"
                android:background="@drawable/round_bg"
                android:ems="10"
                android:inputType="number"
                android:text="Code"
                android:textColor="#a9a9a9" >
            </EditText>

            <EditText
                android:id="@+id/editText2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight=".20"
                android:background="@drawable/round_bg"
                android:ems="10"
                android:inputType="phone"
                android:text="Phone"
                android:textColor="#a9a9a9" />
        </LinearLayout>

        <Button
            android:id="@+id/button1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:background="@android:color/white"
            android:text="Next"
            android:textColor="#0066FF"
            android:textStyle="bold" />
    </LinearLayout>

</RelativeLayout>

round_bg.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="40dp">
 <solid android:color="#EBEBEB"/>
    <corners
     android:bottomRightRadius="5dp"
     android:bottomLeftRadius="5dp"
  android:topLeftRadius="5dp"
  android:topRightRadius="5dp"/>
    <padding android:left="10dp"
        android:top="10dp"
        android:right="10dp"
        android:bottom="10dp"/>
</shape>

我希望这会帮助你。

I hope this will help you.

让我还是知道的任何问题。

Let me know still any issues.

感谢。

这篇关于如何设置在每个控制角落交叉并设置margin和padding在android系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆