0

in der folgenden layout-datei überspannen, ich erstellt eine scrollView und es umfasst eine tableLayout. Die erste Zeile in der Tabelle ist ein Edittext. und trotz i EditText Ansicht Parameter sein, wie folgt:kann nicht erzwingen die edittext width auf dem bildschirm

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

es reicht nie auf dem Bildschirm von links nach rechts !!

Bitte lassen Sie mich wissen, wie der Edittext über den Bildschirm von links nach rechts erstreckt?

Layout-

<?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> 

Antwort

0

ich es gefunden. Ich hätte EditText Blick ins Innere eines Relativelayout für ein Beispiel gewickelt, wie folgt:

  <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> 

aber ich weiß immer noch nicht, warum es nicht ohne funktioniert EditText innerhalb eines Host-Layout Einwickeln ?? !!

0

stretchColumns Attribut von TableLayout kann helfen. wie folgt aus:

<?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

leider ist es nicht – user2121

+0

Seltsamer arbeiten, um es für meine Umgebung (Emulator, Android 6) – nshmura

+0

vielleicht weil im Original-Layout arbeitet, die die, die ich habe, ist, es sind extra drei Tablewars unterhalb der Edittext-Ansicht. sie sind etwas wie die folgenden: x1: x1value x2: x2value x3: x3value – user2121