に垂直センターでウィジェットを設定するには、どのように私は私のhorizontal
LinearLayout
にcenter_vertical
でWidgets
を設定し、親のレイアウトの右側に最後Textview
を設定したいです。はのLinearLayout
私は試しましたが、苦労しています。私は以下の私のコードを含めた。
のxmlレイアウト:ここで
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal"
android:background="@drawable/list_selector">
<ImageView
android:id="@+id/icon"
android:layout_width="25dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:contentDescription="@string/desc_list_item_icon"
android:src="@drawable/image1"
android:layout_centerVertical="true" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/icon"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="@color/colorPrimary"
android:layout_centerVertical="true"
android:text="Hello world"
android:paddingRight="40dp"/>
<TextView android:id="@+id/counter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/counter_bg"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="8dp"
android:textColor="@color/counter_text_color"/>
</LinearLayout>
は私が作るしようとしているものです:
親ビューの向きは 'horizontal'ですが、子ビューは' center_vertical'ですか? –
はいはい私は子供の眺めを維持したいhorizentall – Krish
これは多少矛盾していませんか?作成しようとしているもののサンプル画像***を提供できますか? 'Paint'を使ってみてください。 –