How do I get an ImageView next to a TextView in a Linearlayout?
Like this:
<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
属性。
您可以将两个视图的水平方向设置为线性布局和权重。
Just add another LinearLayout with a horizontal orientation into your vertical 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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.