私はLinearLayout
の特定の正方形のスペースを持っています。このLinearLayout
の中には、RelativeLayout
の高さと幅100dp
があります。このRelativeLayout
は円形の描画可能な形状をしています。 RelativeLayout
の高さと幅を親の利用可能なスペースの合計の60%に設定したいLinearLayout
これを行う方法はありますか?相対レイアウトの高さと幅をパーセンテージで設定する方法
これは、私は、これはあなたがネストされたビューの数を減らすためにPercentRelativeLayoutまたはConstraintLayoutを使用することができます1つの円形のビューの私のXMLコードスニペット
<RelativeLayout
android:id="@+id/rl_hatchback"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/rl_hatchback_circle"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/circle_red"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_hatchback"
android:layout_centerInParent="true"
/>
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/rl_hatchback_circle"
android:text="Hatchback"
style="@style/CircularTitle"
/>
</LinearLayout>
はあなたがそこにある –
1.あなたの割合に応じて、新たな制約レイアウトと設定ガイドラインを使用することができますあなたが達成したいことのための多くの答えは、まさにその60%の高さを持つことです。あなたのレイアウトはとても悪く書かれており、あなたのアプリのパフォーマンスに影響を与えることがあります。 3.ポイント1に返信したら、さらに#1&#2を助けることができます –
このレイアウトを表現する最良の方法を教えてください。 –