私は、Androidに次の図のように4つのボタンを設計する必要があります。どのレイアウトを使用すべきか、60-40%の比率をすべての画面でサイズ変更できるようにする方法についてはわかりません。ありがとうございました!Androidで下のフォーマットをデザインするには
-6
A
答えて
1
、およびlayout_height
LinearLayout (Vertical)
LinearLayout (Horizontal) //layout_weight: 0.4
FrameLayout //layout_weight: 0.4
FrameLayout //layout_weight: 0.6
LinearLayout (Horizontal) //layout_weight: 0.6
FrameLayout //layout_weight: 0.6
FrameLayout //layout_weight: 0.4
注:
match_parent
0dp
に変更した場合は、中に重みを持たなければなりません60%で0.6、40%で0.4のような適切な場所。
コード:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.4">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:background="#d00000"></FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.6"
android:background="#9be412" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.6">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.6"
android:background="#12b9a3" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:background="#b208a7" />
</LinearLayout>
</LinearLayout>
2
あなたは体重属性を使用して、レイアウトを相対することができます。私はあなたのケースに合った例を提供しました。この例では重量和は常に1
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.6">
<Button
android:id="@+id/button_1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.6"
android:background="@color/red"/>
<Button
android:id="@+id/button_2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:background="@color/black"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.4">
<Button
android:id="@+id/button_3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.4"
android:background="@color/green"/>
<Button
android:id="@+id/button_4"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.6"
android:background="@color/orange"/>
</LinearLayout>
である。これは、結果3線形レイアウトを使用し
1
であることに留意されたいです。最初の線形レイアウトは垂直、weigthSum = 2は2線形レイアウトの子で、その重みは1で、各子線形レイアウトは水平になり、2つのボタンがあります。
0
プロジェクトに%support libraryを使用してください。
dependencies {
compile 'com.android.support:percent:xx.x.x'
}
layout_width
への変更なしに、ドラッグアンドドロップした後
<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/top_left"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignParentTop="true"
android:background="#ff44aacc"
app:layout_heightPercent="20%"
app:layout_widthPercent="70%" />
<View
android:id="@+id/top_right"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/top_left"
android:background="#ffe40000"
app:layout_heightPercent="20%"
app:layout_widthPercent="30%" />
<View
android:id="@+id/bottom"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@+id/top_left"
android:background="#ff00ff22"
app:layout_heightPercent="80%" />
</android.support.percent.PercentRelativeLayout>
0
これがお手伝いします..あなたはまた、重量でのLinearLayout使用することができます
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@android:color/black"
android:weightSum="100">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="60"
android:weightSum="100"
android:orientation="horizontal">
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Button1"
android:layout_weight="60"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Button2"
android:layout_weight="40"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="40"
android:weightSum="100"
android:orientation="horizontal">
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Button3"
android:layout_weight="40"/>
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Button4"
android:layout_weight="60"/>
</LinearLayout>
</LinearLayout>
おかげで...
関連する問題
- 1. Androidのデザインは下の画像のようですか?
- 2. AndroidのSDKデザインでイベントをブロードキャストする
- 3. Android Studioのデフォルトのナビゲーションドロワーでスライディングタブをデザインするには?
- 4. Androidカスタムビューをデザインする
- 5. Androidの.xmlデザイン
- 6. Androidラジオアプリのデザイン
- 7. Androidゲームのデザイン
- 8. Androidインターフェイスのデザイン
- 9. Androidレイアウトのデザイン
- 10. Androidプログラムのデザイン
- 11. 以下の画像のようにアンドロイドでダイナミックUIをデザインするには
- 12. Androidでのグラフィックのデザイン
- 13. AndroidでLinearLayoutデザインを作成するには?
- 14. Androidのステータスバーアイコンのデザイン
- 15. CSVをJSONにフォーマットするには?以下は
- 16. アイテムの円をデザインするAndroid
- 17. Android:カレンダーのUIデザイン
- 18. AndroidデザインのゲームカードUI
- 19. Android Appのデザイン - ベストプラクティス?
- 20. AndroidアプリのUIデザイン
- 21. Android素材デザイン
- 22. Android UIデザイン
- 23. ボーダーをdivデザインの下に取得する方法
- 24. タブレットでAndroid UIのデザインが壊れる
- 25. スレッディングに関するヒント+以下のケースのためのデザイン
- 26. Android用のレイアウトをデザインするツール - オンラインでのアプリケーションですか?
- 27. 大規模なテキストユーザーに適したデザインのAndroidデザイン
- 28. Androidアプリケーションで時間をフォーマットする
- 29. AndroidデザインUIエレメントPSD
- 30. デザインは、私は以下のページ持っているIE
ConstraintLayout –
か[PercentLayout](ht tps://developer.android.com/reference/android/support/percent/PercentRelativeLayout.html) – marshallino16
あなたがこれまでに試したことや実際にぶつかったことを追加してください。 –