Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
113 views
in Technique[技术] by (71.8m points)

how to set cross in each control corner and set margin and padding in 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>

Current results and desired results

Current results Desired results

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try out below 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.

Thanks.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...