絶対的なサイズと相対サイズを混ぜるにはどうすればよいですか?
-
27-10-2019 - |
質問
カスタムリストアイテムを作成したいです。基本的には、水平に3つの領域が必要です LinearLayout
. 。最も左のものは幅50dpで、右の幅でもあると考えられています。真ん中にあるものが残りのスペースを取り上げてほしい。最終的には50px |になるはずです幅-100px | 50px。
XMLでこれを行うことはできますか?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:gravity="right" >
<FrameLayout
android:id="@+id/frameLayout1"
android:layout_width="50dp"
android:layout_
android:layout_height="match_parent"
android:layout_weight="0">
</FrameLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="fill"
android:orientation="vertical"
android:layout_weight="0">
</LinearLayout>
<FrameLayout
android:id="@+id/frameLayout2"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_weight="0" >
</FrameLayout>
</LinearLayout>
解決
を設定するだけです layout-weight
中央のアイテムの1から layout_width
に fill_parent
.
所属していません StackOverflow