簡體   English   中英

LinearLayout中TextView旁邊的ImageView

[英]ImageView next to TextView in a LinearLayout

如何在Linearlayout中的TextView旁邊獲取ImageView?

像這樣:

像這樣

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
>
<TextView
    android:layout_width="0dip"
    android:layout_height="fill_parent"
    android:layout_weight="0.75" />
    <ImageView
    android:layout_width="0dip"
    android:layout_height="fill_parent"
    android:layout_weight="0.25"

    />
 </LinearLayout>

您也可以在TextView中嘗試drawableRight屬性。

您可以將兩個視圖的水平方向設置為線性布局和權重。

只需將另一個水平方向的LinearLayout添加到您的垂直LinearLayout中:

<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical">
    <LinearLayout
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:orientation="horizontal">
        <TextView
        android:layout_height="0dp"
        android:layout_width="wrap_content"
        android:layout_weight="3" />
        <ImageView
        android:layout_height="0dp"
        android:layout_width="wrap_content"
        android:layout_weight="1" />
    </LinearLayout>
    <!-- Others layout here -->
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
>

<TextView
    android:layout_width="0dip"
    android:layout_height="fill_parent"
    android:layout_weight="0.75"
    android:textStyle="bold" />

    <ImageView
    android:layout_width="0dip"
    android:layout_height="fill_parent"
    android:layout_weight="0.25"
    />
 </LinearLayout>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM