我在列表視圖中顯示數據。我想要所有的名字都一致。我使用體重,因爲我不希望圖像放置大部分屏幕。但用這種方法我不能以相同的方式對齊圖像。這是它的外觀。 image of pageAndroid - Same Alignment - 佈局
這裏是我的代碼:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:paddingLeft="20dp"
android:scaleType="fitStart"
app:srcCompat="@drawable/food_icon" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="3"
android:paddingLeft="0dp">
<TextView
android:id="@+id/menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="0dp"
android:text="TextView"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<TextView
android:id="@+id/cost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView"
android:textSize="14sp" />
<TextView
android:id="@+id/owner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
我需要幫助。謝謝你...
你爲什麼嵌套LinearLayouts?你能發表你想要它的樣子麼? – Nick
android:gravity =「left」使用此菜單文本編號 –
@Nick這就是我想要的,但我也希望所有的名字都以相同的顏色開始。也許我不能用英文解釋它。我想要名稱以相同的X座標開始。例如,看喬和Stevekjflk不以相同座標開始 –