0

テーブルレイアウトの最初の行はEdittextです。私は以下のようにEDITTEXTビューパラメータ を設定するにもかかわらず、そして:私はscrolltviewを作成し、それはtableLayoutを取り囲んでいます。edittext幅を画面に沿って広げるように強制します。

android:layout_width="match_parent" 
android:layout_height="wrap_content" 

それは左から右に画面に沿ってまたがることはありません!

Edittextを画面の左から右に広げる方法を教えてください。

レイアウト

<?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" android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> 

<!-- scrollView can host only one direct parent--> 
<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <TableLayout 
     android:id="@+id/tl1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 
     <TableRow 
      android:id="@+id/tr0" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 
      <EditText 
       android:id="@+id/et0" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"/> 
     </TableRow> 
     <TableRow 
      android:id="@+id/tr1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:weightSum="3" 
      android:orientation="vertical"> 

      <RelativeLayout 
       android:id="@+id/rl_label_x1" 
       android:layout_weight="1"> 
       <TextView 
        android:id="@+id/tv_label_x1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="x1: "/> 
       <TextView 
        android:id="@+id/tv_x1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_toEndOf="@id/tv_label_x1" 
        android:text="x1value" /> 
      </RelativeLayout> 
     </TableRow> 
    </TableLayout> 
</ScrollView> 
</RelativeLayout> 

答えて

0

私はそれを発見しました。

  <RelativeLayout 
       android:id="@+id/rl_et" 
       android:layout_weight="1"> 
      <EditText 
       android:id="@+id/et0" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"/> 
      </RelativeLayout> 

をしかし、それは、ホストレイアウト内のEditTextをラップせずに動作しない理由を私はまだ知らない?? !!:次のように私は、例えばRelativelayout内部のEditTextビューをラップしている必要があります

0

stretchColumns属性がTableLayoutの場合があります。このような :

<?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" 
       android:paddingLeft="@dimen/activity_horizontal_margin" 
       android:paddingRight="@dimen/activity_horizontal_margin" 
       android:paddingTop="@dimen/activity_vertical_margin" 
       android:paddingBottom="@dimen/activity_vertical_margin" 
       tools:context=".MainActivity"> 

    <!-- scrollView can host only one direct parent--> 
    <ScrollView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

     <TableLayout 
       android:id="@+id/tl1" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" 
       android:stretchColumns="0"> 

      <TableRow 
        android:id="@+id/tr0" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 
       <EditText 
         android:id="@+id/et0" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content"/> 
      </TableRow> 
      <TableRow 
        android:id="@+id/tr1" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:weightSum="3" 
        android:orientation="vertical"> 

       <RelativeLayout 
         android:id="@+id/rl_label_x1" 
         android:layout_weight="1"> 
        <TextView 
          android:id="@+id/tv_label_x1" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="x1: "/> 
        <TextView 
          android:id="@+id/tv_x1" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_toEndOf="@id/tv_label_x1" 
          android:text="x1value"/> 
       </RelativeLayout> 
      </TableRow> 
     </TableLayout> 
    </ScrollView> 
</RelativeLayout> 

enter image description here

+0

残念ながらそれは私が持っているものです元のレイアウトでは、余分があるかもしれないので – user2121

+0

それは私の的環境のために働く不思議(エミュレータ、Androidの6) – nshmura

+0

を動作しません。 Edittextビューの下に3つのtablerows。彼らは次のようなものです:x1:x1value x2:x2value x3:x3value – user2121

関連する問題