2017-02-15 3 views
0

私は絵にこのようなレイアウトを行う必要があります。AndroidでLinearLayoutデザインを作成するには?

enter image description here

ここSpinner値、そして我々は携帯電話番号を入れて持っている1 EditTextに応じて変化する国があります。 EditTextは、 - の形式を持つ必要があります。国コードはAPIから取得され、その番号はユーザーによって供給されます。しかし、これはEditTextとしてのみ表示され、TextViewと表示されず、LinearLayoutにはEditTextと表示されます。

どうすればこの問題を解決できますか?

あなたがこれを達成することができますいくつかの方法があります
<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> 
+0

絵がある後、彼の携帯電話番号を入力し続けることができれば、その後最初のテキストを編集するためのAPI値を設定すると思いますか? – user3040153

+0

OKアップロードをもう一度待ちます – user7316606

+0

plzもう一度私はアップロードしました – user7316606

答えて

0
create background.xml in drawable & add this as background of edit text & spinner 

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <solid android:color="#00000000"/> <-- transparent--> 
    <stroke android:color="@color/grey" <-- grey color--> 
     android:width="10dp"/> 
    <corners 
     android:bottomLeftRadius="30dp" 
     android:bottomRightRadius="30dp" 
     android:topLeftRadius="30dp" 
     android:topRightRadius="30dp"/> 
</shape> 
+0

ok let try try .. – user7316606

+0

テキストの高さの幅がスピナーと同じではない – user7316606

+0

このコードは、レイアウトxmlに幅を与える必要があるだけの背景を作成します – user3040153

0

  1. あなたはSpinnerや他のEditText Sに入れている背景を持っているLinearLayoutを作成します。 水平の向きを付けて、TextView(APIの国コードを含む)とEditTextを追加します(ユーザーはweight = 1、背景なし)。これにより簡単に同じ結果が得られます。
  2. Stringをコード内に作成します(countryCode)。これにはAPIの国コードを格納します。 EditTextTextWatcherを追加し、接頭辞countryCodeを入力に追加します。 注:onTextChanged()コールバック内のフィールドのテキストを変更することは、infi-loopをトリガーする可能性があるのでお勧めできません。
0

は、私はあなたが単にテキスト編集フィールド上のユーザーのクリックは、彼が国コード

+0

gudオプション..私は試してみてください – user7316606

関連する問題