私は、カスタムアダプタを使用してリストビューに使用する線形レイアウトを持ち、画像と2つのテキストビューで構成されています。 私の問題は、最初のテキストビューの長さは必ずしも同じではないので、すべての2番目のテキストビューを同じ位置に揃える方法はわかりません。線形レイアウトの要素を右に配置
row.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView1"
android:layout_gravity="center"
android:layout_width="48dp"
android:layout_margin="5dp"
android:layout_height="48dp"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/textView1"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25dp"
android:text="TextView" />
<TextView
android:id="@+id/textView2"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/txtresultadocolor"
android:textSize="25dp"
android:layout_marginLeft="15dp"
/>
これが今の私のコードですが、2番目のテキストビューは常に変化します。 私は助けていただければ幸いです。
あなたが達成しようとしている結果とは何ですか?各TextViewが特定の割合の水平スペースを占めるようにすることは可能です。また、固定幅の2番目のTextViewを作成するオプションです。 – foxanna
考え方:1.利用可能な合計幅に基づいて 'TextView'の幅を計算します。 2.もし 'LinearLayout'の代わりに 'RelativeLayout'を使い、' TextView'を親の始点に、そして他のものを親の終点に合わせます。 4. 'GridLayout'または' TableLayout'を使用してください。 –