1

私はTextViewとEditTextを持っていますが、これは適切なスパンで行を整列させる必要があります。現在のレイアウトで行内のtextviewとedittextの幅を調整して調整します。

、のEditTextが整列されていますが、縮め表示され、残りの幅

enter image description here

のXml取っていない:あなたはのEditTextが残りのスペースを埋めるためにしたい場合は

<TableLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     tools:style="@style/AppTheme" 
     android:layout_marginBottom="10dp" 
     android:layout_marginTop="10dp"> 

     <TableRow> 
      <TextView 
       style="@style/AppTheme.DetailInfo" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="New Password:" /> 
      <EditText 
       style="@style/AppTheme.TextBox" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:inputType="textPassword" 
       android:maxLines="1" 
       android:text= "@={profile.password}"/> 
     </TableRow> 
    </TableLayout> 
+1

幅が 'wrap_content'に設定されていて、edittextが瞬間に空である可能性があります –

+0

stretchcolumnsとshrinkcolumnsプロパティを使用できます。https://stackoverflow.com/questions/32331368/how-do-androidshrinkcolumns-and- androidstretchcolumns-work –

答えて

2

をlayout_width = "0dp"とlayout_weight = "1"を設定する必要があります。参照:

https://developer.android.com/guide/topics/ui/layout/linear.html#Weight

「たとえば、そこに3つのテキストフィールドがあり、他は何の重みを与えられていない間、彼ら二人は、1の重みを宣言した場合、重量のない3番目のテキストフィールドが成長し、意志はありませんそのコンテンツが必要とする領域だけを占有する」

編集:編集テキストの先頭を揃えるには、すべてのテキストビューに同じ重みを適用し、すべての編集テキストに同じ重みを適用する必要があります。元の答えは、編集テキストの先頭を整列させずに、残りのスペースを埋めるだけです。

関連する問題