2

テキスト ビューとボタンを含む Android アプリケーションを開発しています。

テキスト ビューの直後に Button を配置する必要があります。私の TextView がうまく機能している単一行の場合。しかし、複数行のテキストビューを使用すると、ボタンが1行目の最後に配置されました。

ボタンを正しい位置に配置する方法 (テキストビューの最後の行の後)?

編集後:
これは私の xml です。コードで使用し、動的に生成します。

<TableLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:shrinkColumns="1"
android:stretchColumns="1"  >

   <TableRow android:id="@+id/tableRow1" >
 <Button
    android:id="@+id/ayehPlace_btnCounter"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/ayeh_counter"
    android:text="" />
<TextView
    android:id="@+id/ayehPlace_txtAyeh"
    android:layout_width="wrap_content"
    style="@style/ayehPlace_txt"
    android:layout_height="wrap_content"
    android:text="" /> 
</TableRow>
</TableLayout>
4

4 に答える 4

1

代わりにテーブルレイアウトを使用してください....私にとってはうまくいきました..

<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingTop="10dp"
    android:shrinkColumns="1"
    android:stretchColumns="1" >

    <TableRow
        android:descendantFocusability="beforeDescendants"
        android:focusable="true"
        android:focusableInTouchMode="true" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Your Text" />

        <Button
            android:id="@+id/button_id"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=""/>
    </TableRow>
    </TableLayout>  
于 2013-06-25T06:50:29.947 に答える
0

android:gravity="bottom" と一緒に TableLayout を使用する必要があると思います。それを試してみてください。

于 2013-06-25T07:10:24.363 に答える
0

代わりにテーブル レイアウトを使用することをお勧めします。これにより、UI が統一され、自動的に調整されます。

<TableLayout
       xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="fill_parent"
       android:layout_height="match_parent"
       android:padding="5dp"
       android:shrinkColumns="1"
       android:stretchColumns="1" >

       <TableRow android:id="@+id/tableRow1" >

           <TextView
               android:id="@+id/textView1"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:text="Main Status             "
               android:textAppearance="?android:attr/textAppearanceMedium" />

           <Button
               android:id="@+id/retentionMainStatus"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:text="CLICK ME" />
</TableRow>
</TableLayout>
于 2013-06-25T06:06:19.653 に答える
0

RelativeLayout を使用して追加する

android:layout_toRightOf="@+id/textviewid" 

ボタンに。

于 2013-06-25T05:50:54.473 に答える