2017-02-15 5 views
0

Ich brauche ein Layout wie dies in Bild zu machen:Wie man LinearLayout Design in Android machen?

enter image description here

Hier Land, das nach Spinner Wert ändert, ist, und 1 EditText wo wir Handy-Nummer setzen müssen. Die EditText muss das Format haben -. Der Ländercode wird von einer API abgerufen und die Nummer wird vom Benutzer eingegeben. Aber dies sollte nur als EditText erscheinen, nicht als TextView und EditText in einer LinearLayout.

Wie kann ich das erreichen?

<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

Typ ist Bild? – user3040153

+0

ok warte ich wieder – user7316606

+0

laden plz sehen wieder hochgeladen ich wieder – user7316606

Antwort

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 lassen Sie mich versuchen .. – user7316606

+0

aber bearbeiten Texthöhe Breite ist nicht so gleich wie Spinner – user7316606

+0

dieser Code erstellen nur Hintergrund Sie Breite in Ihrem Layout xml – user3040153

0

Es gibt ein paar Möglichkeiten, wie Sie dies erreichen können,

  1. ein LinearLayout erstellen, die den Hintergrund hat, die Sie in dem Spinner und anderen EditText s setzen sind. Gib es horizontal Orientierung und fügen Sie eine TextView (um den Ländercode aus Ihrer API enthalten) und eine EditText, dass der Benutzer seine Nummer eingeben kann (vorzugsweise mit weight = 1, und kein Hintergrund). Dies würde auf einfache Weise dasselbe erreichen.
  2. Erstellen Sie eine String namens countryCode in Code, speichern Sie den Ländercode aus der API in diesem. Fügen Sie TextWatcher zu Ihrem EditText und Präfix countryCode dem Eingang hinzu. Hinweis: Das Ändern des Textes eines Felds innerhalb eines onTextChanged() Callbacks wird nicht empfohlen, da Sie möglicherweise eine Infi-Schleife auslösen können.
0

Ich glaube, Sie einfach api Wert Text bearbeiten zuerst, dass nach, wenn der Benutzer klicken Sie auf das Textfeld bearbeiten er seine Handy-Nummer nach dem Ländercode weiter, wo

+0

gud geben müssen Option ..Lass mich versuchen – user7316606

Verwandte Themen