blog

レイアウト・オーバーレイを使用して、難しいビュー・レイアウトの問題を解決する

要件は、まず右側を適応させ、次に中央を適応させ、最後に左側を適応させるのですが、表示できる大きさが足りない...。 難しいのは、このような問題を設計する場合、開発過程で、通常のレイアウトでは常に右側が...

Jun 18, 2020 · 2 min. read
シェア

まず右側を適応させ、次に中央を適応させ、最後に左側を適応させなければならない。...
その難しさは、開発中、この種の問題の通常の設計方法は常にレイアウトの右側を絞ることであり、レイアウトの右側をサイズに適応させることは不可能であるという事実にある。.
この問題は、以下のようにレイアウトを入れ子にすることで解決できる。.
<RelativeLayout
 android:paddingLeft="@dimen/x8"
 android:layout_width="match_parent"
 android:layout_height="wrap_content">
 <LinearLayout
 android:id="@+id/topName"
 android:paddingLeft="@dimen/x18"
 android:layout_marginTop="@dimen/x16"
 android:layout_toLeftOf="@+id/check_box"
 android:layout_marginRight="@dimen/x21"
 android:gravity="center_vertical"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:orientation="horizontal">
 <LinearLayout
 android:layout_width="wrap_content"
 android:layout_height="wrap_content">
 <TextView
 android:id="@+id/item_name"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 tools:text="コース・ノード名 コース・ノード名 コース・ノード名 コース・ノード名 "
 android:singleLine="true"
 android:ellipsize="end"
 android:layout_weight="1"
 android:textColor="@color/c_2b2d44"
 android:textSize="@dimen/x16"
 />
 <TextView
 android:id="@+id/item_type"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_marginLeft="@dimen/x8"
 android:paddingTop="@dimen/x2"
 android:paddingBottom="@dimen/x2"
 android:paddingLeft="@dimen/x4"
 tools:text=" 
 android:paddingRight="@dimen/x4"
 android:background="@drawable/bg_corner_radius2_f1f1f1"
 android:textColor="@color/c_6a6c7c"
 android:textSize="@dimen/x10" />
 </LinearLayout>
 </LinearLayout>
 <ImageView
 android:id="@+id/check_box"
 android:src="@drawable/icon_download_check_nomal_weektask"
 android:layout_alignParentRight="true"
 android:layout_marginRight="@dimen/x18"
 android:layout_marginTop="@dimen/x21"
 android:layout_width="@dimen/x22"
 android:layout_height="@dimen/x22"/>
 </RelativeLayout>
Read next

Objective-Cにおけるアトミックと非アトミック入門。

アトミックについて説明する前に、アトミックとアトミック演算が実際にどのようなものかを見ておくことが重要です。原子とは、その名前が示すように、最小の不可分な粒子です。ここではクォーク粒子を方程式から除外して、原子という言葉を象徴することができます。アトミック操作とは、1つまたは一連の不可分でブロック化された操作のことです。 Objective-Cでは、プロパティはデフォルトでアトミックです。公式ドキュメントによると...

Jun 18, 2020 · 3 min read