繁体   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