如何在Android中进行LinearLayout设计? [英] How to make LinearLayout design in Android?
问题描述
我需要在图片中进行如下布局:
I need to make a layout like this in picture:
这里有一个国家,根据Spinner
值和1 EditText
值而变化,我们必须在其中输入手机号码. EditText
必须具有-格式.国家/地区代码是从API中提取的,而号码则由用户提供.但是,它应该仅显示为一个EditText
,而不显示为TextView
和LinearLayout
中的EditText
.
Here there is country which changes according to Spinner
value , and 1 EditText
where we have to put mobile number. The EditText
needs to have the format -. The country code is fetched from an API and the number is fed by the user. But, this should appear as one EditText
only, not as a TextView
and an EditText
in a LinearLayout
.
我该如何实现?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:fb="http://schemas.android.com/apk/res-auto"
android:background="@drawable/common_bg"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context="com.pigeonmarket.PMRegisterActivity">
<!-- Login progress -->
<ProgressBar
android:id="@+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:visibility="gone" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/registerform"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp">
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/toolbar_new"
android:layout_centerHorizontal="true"
android:text="REGISTER"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#fff"
android:textSize="18dp" />
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:background="@drawable/signup_icon" />
<EditText
android:id="@+id/sname"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="14dp"
android:hint="Name"
android:paddingLeft="15dp"
android:textSize="14dp"
android:layout_below="@+id/imageView"
android:layout_centerHorizontal="true" />
<Spinner
android:layout_width="match_parent"
android:layout_height="60dp"
style="?android:attr/spinnerItemStyle"
android:id="@+id/fbcountry"
android:paddingLeft="15dp"
android:layout_marginTop="12dp"
android:drawableRight="@drawable/down_arrow"
android:drawablePadding="15dp"
android:paddingRight="15dp"
android:spinnerMode="dialog"
android:layout_below="@+id/sname"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="60dp"
android:paddingLeft="35dp"
android:layout_below="@+id/fbcountry"
android:layout_alignR="@+id/fbcountry"
android:hint="+"
android:layout_marginTop="30dp"
android:textSize="14dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="60dp"
android:paddingLeft="50dp"
android:layout_below="@+id/fbcountry"
android:layout_alignR="@+id/fbcountry"
android:hint="code"
android:layout_marginTop="30dp"
android:textSize="14dp"
android:id="@+id/calling_code" />
<EditText
android:layout_width="wrap_content"
android:layout_height="60dp"
android:paddingLeft="90dp"
android:layout_below="@+id/fbcountry"
android:layout_alignR="@+id/fbcountry"
android:hint="Mobile Number"
android:layout_marginTop="10dp"
android:textSize="14dp"
android:id="@+id/mob" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
推荐答案
我认为您只需设置api值即可首先编辑文本,然后,如果用户单击编辑文本"字段,他可以继续在国家/地区代码后输入手机号码
i think you simply set api value to edit text first after that if user click on the Edit Text field he can continue type his mobile number after the country code
这篇关于如何在Android中进行LinearLayout设计?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!