I would like to know how I can put 3 different elements with different widths in the same line?
Like below
LinearLayout with Horizontal orientation (parent) within that, Textview(50% width-align left)ImageView(25% width-align right)Textview(25% width-align right) all in the same line?
Please help.
You can use LinearLayout
with weight
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_landing"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.50"
android:text="1" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:text="2" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:text="3" />
</LinearLayout>
You can use PercentRelativeLayout
see this answer
您可以在水平方向的LinearLayout中使用3个具有相对权重的RelativeLayouts。
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.