私は動的にレイアウトを生成しています。これを行うには、繰り返す行構造を含むmenu_row_element.xmlファイルがあります。ImageViewをスクリーンから押し出さないようにTextViewを設定する方法
イメージを含むLinearLayout(水平)、小さいイメージの上に大きなテキスト、右矢印を持つImageView(別のLinearLayoutの中で右揃えにする)で構成されます。
テキスト部分が小さい場合、すべてが正常に見えます。ただし、テキスト部分が長い場合は、右矢印が画面から押し出されます。
どうすれば右矢印を画面上に常に正しく配置し、テキストビューでテキストを適切に折り返すことができますか?
このイメージでは、テキストは小さいので、最後の行はOKですが、行1と2は画面から右矢印を押します。
a busy cat http://img706.imageshack.us/img706/2927/device20111221203115.jpg
xmlファイルは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:clickable="true"
android:background="@drawable/main_menu_button"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:orientation="horizontal"
android:gravity="left|center_vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<!-- Icon of each section -->
<ImageView
android:id="@+id/menu_icon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:padding="10px" />
<!-- Text, in two parts -->
<LinearLayout
android:orientation="vertical"
android:paddingLeft="10px"
android:layout_width="wrap_content"
android:layout_height="fill_parent">
<!-- Big font text -->
<TextView
android:id="@+id/menu_element_big_text"
android:textSize="20dp"
android:textColor="@color/black"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<!-- Small font text -->
<TextView
android:id="@+id/menu_element_small_text"
android:scrollHorizontally="false"
android:textSize="15dp"
android:textColor="@color/black"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<!-- Layout just to be able to right align, sheesh! -->
<LinearLayout
android:gravity="right|center_vertical"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:padding="0dp"
android:src="@drawable/right" />
</LinearLayout>
</LinearLayout>
ありがとう!
それは外側のLinearLayoutを持っていることが必要ですか? – zundi
外のLinearLayoutなしでこれを試してみましたが、うまくいくようです。ありがとう! – zundi