2016-12-26 5 views
0

formAndroidでこのフォームを作成するにはどうすればよいですか?

私はこの小さなフォームをAndroidで作成しようとしましたが、3番目と4番目の行にスペースを作成できませんでした。

+0

これまでに行ったことを投稿する必要があります。助けが簡単です。 – davidxxx

+0

申し訳ありませんStackoverflowは、画像をアップロードするには少なくとも10ポイントが必要だと言います。私は現在6です。 –

答えて

0

このような何か:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

<TextView 
    android:id="@+id/text" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Apellidos"/> 

<EditText 
    android:id="@+id/editText" 
    android:layout_toRightOf="@+id/text" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:hind="Apellidos"/> 


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

    <RelativeLayout 
     android:layout_weight="1" 
     android:layout_marginRight="20dp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 

     <TextView 
      android:id="@+id/text2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerVertical="true" 
      android:text="Ciudad"/> 

     <EditText 
      android:layout_toRightOf="@+id/text2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:hind="Apellidos"/> 

    </RelativeLayout> 

    <RelativeLayout 
     android:layout_marginLeft="20dp" 
     android:layout_weight="1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 

     <TextView 
      android:id="@+id/text3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerVertical="true" 
      android:text="Ciudad"/> 

     <EditText 
      android:layout_toRightOf="@+id/text3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:hind="Apellidos"/> 

    </RelativeLayout> 

</LinearLayout> 

</RelativeLayout> 

編集:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" android:layout_width="match_parent" 
android:layout_height="match_parent"> 


<LinearLayout 
    android:id="@+id/name" 
    android:orientation="vertical" 
    android:gravity="right" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent"> 
    <TextView 
     android:id="@+id/text" 
     android:padding="10dp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Apellidos"/> 

    <TextView 
     android:id="@+id/text1" 
     android:padding="10dp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Apelli"/> 

</LinearLayout> 

<LinearLayout 
    android:id="@+id/value" 
    android:orientation="vertical" 
    android:layout_toRightOf="@+id/name" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <EditText 
     android:id="@+id/editText" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@+id/text" 
     android:hind="Apellidos" /> 

    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <EditText 
      android:layout_weight="2" 
      android:layout_toRightOf="@+id/text2" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="10dp" 
      android:hind="Apellidos"/> 

     <TextView 
      android:layout_marginLeft="10dp" 
      android:layout_weight="1" 
      android:id="@+id/text2" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:text="Ciudad"/> 

     <EditText 
      android:layout_weight="2" 
      android:layout_toRightOf="@+id/text2" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:hind="xyz"/> 

    </LinearLayout> 


</LinearLayout> 

+0

それは考えですが、コンポーネントが整列していません –

+0

あなたは左側のtextviewsが整列していないことを意味しますか?はいの場合は、スペースにテキストを追加して、すべて同じ長さにする必要があります – khetanrajesh

+0

そうです。私はそれを試して、それが働いたが、私は国際化が行われるときに心配する –

1

あなたはRelativeLayoutを使用して、これを実装することができますが、それはあなたが指定できますConstraintLayoutを使用するための理想的な候補であります要素の相対的な位置と、タブレットまたはマルチウィンドウモードでウィンドウのサイズが変更されるときに、どのように展開/再配置する必要があるかを示します。

関連する問題