2016-05-03 7 views
0

Ich versuche herauszufinden, wie das unten genannte Eingabeformular zu gestalten. Bisher habe ich TableLayout versucht, dies zu tun. Unten ist mein Code. Aber scheiterte. Bitte schlagen Sie mir vor, wie Sie dies erreichen, jeder Kommentar, Code, Aufwand würde geschätzt werden.Android Eingabe Formular Design mit TableLayout

  <TableLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:background="#FF939393"> 
      <TableRow 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       android:background="#FF000000" 
       android:layout_margin="1dp" 
       android:weightSum="2"> 

       <TextView 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:text="First Name"/> 

       <TextView 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:layout_marginLeft="1dp" 
        android:text="Last Name" /> 
      </TableRow> 
      <TableRow 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       android:background="#FF000000" 
       android:layout_margin="1dp"> 
       <TextView 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="Email"/> 

      </TableRow> 

     </TableLayout> 

enter image description here

+0

Ersetzen Sie Ihre Textansichten mit Text Widget bearbeiten! – Sathish

+0

Warum verwenden Sie speziell ein 'TableLayout'? Nachdem du deinen Code angeschaut hast, hast du eigentlich schon was du willst. Das einzige, was fehlt, ist das Konto TextView oben erstellen? –

+0

Ich sollte TableLayout nicht speziell verwenden. Ich habe gerade versucht, mein Problem damit zu lösen. Das Hauptproblem ist die vertikale Linie. – IPL10

Antwort

0

Endlich finde ich einen Weg von oben Vorschläge zu erreichen. Unten wird der Arbeitscode erwähnt.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#FF000000"> 

<ScrollView 
    android:id="@+id/scroll_view" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:fillViewport="true"> 
    <LinearLayout 
     android:id="@+id/myLayout" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fillViewport="true"> 

     <TextView 
      android:id="@+id/bodytext" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Create Account" 
      android:textColor="@color/colorGrayText" 
      android:layout_gravity="center_horizontal" 
      android:layout_margin="5dp" 
      android:textSize="22sp"/> 

     <View 
      android:layout_width="fill_parent" 
      android:layout_height="1dp" 
      android:background="#E8393939" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp"/> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="50dp" 
      android:orientation="horizontal" 
      android:weightSum="2" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp"> 

      <EditText 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.99" 
       android:background="@android:color/transparent" 
       android:layout_gravity="center" 
       android:paddingLeft="5dp" 
       android:hint="First Name"/> 
      <View 
       android:layout_width="0dp" 
       android:layout_height="50dp" 
       android:layout_weight="0.01" 
       android:background="#E8393939"/> 
      <EditText 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:background="@android:color/transparent" 
       android:layout_gravity="center" 
       android:paddingLeft="5dp" 
       android:hint="Last Name"/> 

     </LinearLayout> 
     <View 
      android:layout_width="fill_parent" 
      android:layout_height="1dp" 
      android:background="#E8393939" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp"/> 
     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="50dp" 
      android:orientation="horizontal" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp"> 

      <EditText 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:background="@android:color/transparent" 
       android:layout_gravity="center" 
       android:paddingLeft="5dp" 
       android:hint="Email Address"/> 
     </LinearLayout> 
     <View 
      android:layout_width="fill_parent" 
      android:layout_height="1dp" 
      android:background="#E8393939" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp"/> 
     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="50dp" 
      android:orientation="horizontal" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp"> 

      <EditText 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:background="@android:color/transparent" 
       android:layout_gravity="center" 
       android:paddingLeft="5dp" 
       android:hint="Job Title/Business Title"/> 
     </LinearLayout> 
     <View 
      android:layout_width="fill_parent" 
      android:layout_height="1dp" 
      android:background="#E8393939" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp"/> 
     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="50dp" 
      android:orientation="horizontal" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp"> 

      <EditText 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:background="@android:color/transparent" 
       android:layout_gravity="center" 
       android:paddingLeft="5dp" 
       android:hint="Department"/> 
     </LinearLayout> 
     <View 
      android:layout_width="fill_parent" 
      android:layout_height="1dp" 
      android:background="#E8393939" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp"/> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="50dp" 
      android:orientation="horizontal" 
      android:weightSum="2" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp"> 

      <TextView 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.3" 
       android:background="@android:color/transparent" 
       android:layout_gravity="center" 
       android:paddingLeft="5dp" 
       android:text="+91"/> 
      <View 
       android:layout_width="0dp" 
       android:layout_height="50dp" 
       android:layout_weight="0.01" 
       android:background="#E8393939"/> 
      <EditText 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1.4" 
       android:background="@android:color/transparent" 
       android:layout_gravity="center" 
       android:paddingLeft="5dp" 
       android:hint="Phone number(Optional)"/> 

     </LinearLayout> 
     <View 
      android:layout_width="fill_parent" 
      android:layout_height="1dp" 
      android:background="#E8393939" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp"/> 

    </LinearLayout> 
    </ScrollView> 
</RelativeLayout> 
0

Ihre Textviews Ersetzen mit EditTexts

 <TableLayout 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:background="#FF939393"> 
      <TableRow 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:orientation="horizontal" 
         android:background="#FF000000" 
         android:layout_margin="1dp" 
         > 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Create Account" /> 
     </TableRow> 
        <TableRow 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:orientation="horizontal" 
         android:background="#FF000000" 
         android:layout_margin="1dp" 
         android:weightSum="2"> 

         <EditText 
          android:layout_width="0dp" 
          android:layout_height="wrap_content" 
          android:layout_weight="1" 
          android:hint="First Name"/> 

         <EditText 
          android:layout_width="0dp" 
          android:layout_height="wrap_content" 
          android:layout_weight="1" 
          android:layout_marginLeft="1dp" 
          android:hint="Last Name" /> 
        </TableRow> 
        <TableRow 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:orientation="horizontal" 
         android:background="#FF000000" 
         android:layout_margin="1dp"> 
         <EditText 
          android:layout_width="fill_parent" 
          android:layout_height="wrap_content" 
          android:hint="Email"/> 

        </TableRow> 

       </TableLayout> 
0

den folgenden Code Versuchen. Es ist wie dein Bild. Versuchen

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 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"> 

    <TableLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="#FF939393"> 
     <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:background="#FF000000" 
      android:paddingTop="8dp" 
      android:paddingBottom="8dp" 
      android:gravity="center" 
      android:layout_margin="1dp"> 
      <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="Create Account"/> 

     </TableRow> 
     <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:background="#FF000000" 
      android:layout_margin="1dp" 

      android:weightSum="2"> 

      <EditText 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:layout_marginTop="8dp" 
       android:layout_marginBottom="8dp" 
       android:hint="First Name"/> 
      <View 
       android:layout_width="1dp" 
       android:layout_height="match_parent" 
       android:background="#FF939393"></View> 

      <EditText 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:layout_marginTop="8dp" 
       android:layout_marginBottom="8dp" 
       android:layout_marginLeft="1dp" 
       android:hint="Last Name" 
       /> 
     </TableRow> 
     <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:background="#FF000000" 
      android:paddingTop="8dp" 
      android:paddingBottom="8dp" 
      android:paddingLeft="8dp" 
      android:layout_margin="1dp"> 
      <EditText 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:hint="Email"/> 

     </TableRow> 

    </TableLayout> 
</RelativeLayout> 
+0

Wird das 'RelativeLayout' nicht mehr benötigt? –

+0

Sir wo ist die vertikale Linie? Das ist das Hauptanliegen. – IPL10

+0

warten, ich aktualisiere – Masum

0

Diese

<?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:orientation="vertical"> 


<TextView 
    android:id="@+id/textView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:text="Create Account" 
    android:textSize="20sp" 
    android:textStyle="bold" /> 


<View 
    android:id="@+id/view1" 
    android:layout_width="fill_parent" 
    android:layout_height="2dp" 
    android:layout_below="@+id/textView" 
    android:background="#c0c0c0" /> 

<LinearLayout 
    android:id="@+id/ll" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/view1" 
    android:orientation="horizontal"> 

    <EditText 
     android:id="@+id/editText" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_margin="5dp" 
     android:layout_weight="50" 
     android:hint="Name" /> 

    <View 
     android:layout_width="1dp" 
     android:layout_height="fill_parent" 
     android:background="#c0c0c0" /> 

    <EditText 
     android:id="@+id/editText2" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_margin="5dp" 
     android:layout_weight="50" 
     android:hint="Name2" /> 
</LinearLayout> 


<View 
    android:id="@+id/view2" 
    android:layout_width="fill_parent" 
    android:layout_height="2dp" 
    android:layout_below="@+id/ll" 

    android:background="#c0c0c0" /> 


<EditText 
    android:id="@+id/editText3" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/view2" 
    android:layout_margin="5dp" 
    android:hint="Email" 
    android:inputType="textEmailAddress" /> 

+0

Wo ist die vertikale Linie? – IPL10

+0

Mann, fügen Sie einfach eine Ansicht hinzu. – DKV

+0

aktualisierte meine Antwort. Überprüfen Sie bitte das. – DKV

0
<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="wrap_content" 
    android:orientation="vertical"> 

    <LinearLayout android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:padding="10dp"> 
    <TextView android:layout_width="match_parent" android:gravity="center_horizontal" 
     android:layout_height="wrap_content" android:text="Create Account"/> 
    </LinearLayout> 
    <LinearLayout android:layout_width="match_parent" 
     android:padding="10dp" 
     android:weightSum="2" 
     android:layout_height="wrap_content" android:orientation="horizontal"> 
    <TextView android:layout_width="0dp" android:layout_height="wrap_content" 
     android:gravity="center_horizontal" 
     android:layout_weight="1" 
     android:text="First Name"/> 
    <TextView android:layout_width="0dp" android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:gravity="center_horizontal" 
     android:text="Last Name"/> 
    </LinearLayout> 

    <LinearLayout android:layout_width="match_parent" 
     android:padding="10dp" 
     android:layout_height="wrap_content"> 
    <TextView android:layout_width="match_parent" android:layout_height="wrap_content" 
     android:text="Email address"/> 
    </LinearLayout> 
</LinearLayout> 
+0

Sir wo ist die vertikale Linie. Das Hauptproblem ist die vertikale Linie. – IPL10

+0

können Sie nicht erwarten, dass die gleiche ui aus dem Forum .. haben das grundlegende Layout, fügen Sie Grenze zu ihm .. überprüfen Sie diese http://StackOverflow.com/A/15111469/1066839 – John

0

diesen Code Versuchen.

Hinweis:Change Background Color as you Want

Dies auch Vertical and Horizontal Lines in it.

<?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="#FFFFFF"> 

    <TextView 
     android:id="@+id/tvAccount" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="10dp" 
     android:gravity="center" 
     android:text="@string/account" 
     android:textSize="25sp" /> 

    <View 
     android:id="@+id/separator" 
     android:layout_width="fill_parent" 
     android:layout_height="1dip" 
     android:layout_below="@+id/tvAccount" 
     android:layout_centerVertical="true" 
     android:background="#000000" /> 


    <TableLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/separator"> 


     <TableRow 
      android:id="@+id/row1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:background="#FFFFFF" 
      android:orientation="horizontal" 
      android:weightSum="2"> 

      <EditText 
       android:id="@+id/edtFirstName" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:hint="@string/first_name" 
       android:text="@string/first_name" 
       android:textColorHint="#0000000" /> 

      <View 
       android:layout_width="0.5dp" 
       android:layout_height="35dp" 
       android:background="#000000" /> 

      <EditText 
       android:id="@+id/edtLastName" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:hint="@string/last_name" 
       android:text="@string/last_name" 
       android:textColorHint="#FFFFFF" /> 


     </TableRow> 

     <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_margin="1dp" 
      android:background="#FFFFFF" 
      android:orientation="horizontal" 
      android:weightSum="1"> 


      <EditText 
       android:id="@+id/edtEmail" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:hint="@string/email" 
       android:inputType="textEmailAddress" 
       android:text="@string/email" 
       android:textColorHint="#000000" /> 

     </TableRow> 

    </TableLayout> 


</RelativeLayout> 

Schuss Hier Bildschirm enthält.

enter image description here

+0

@ Jaydroider danke für Ihre Bemühungen, aber vertikale Linie ist nicht so platziert, wie es sein sollte. – IPL10

+0

@IPL check Ich habe XML-Code bearbeitet. lass es mich wissen, es funktioniert oder nicht. –

+0

@IPL Schätze die Antwort von upvote, wenn es dir hilft, danke :). –