/ / Упорядкувати екран у шаблоні 3x3 - java, android, xml, view, imagebutton

Упорядкувати екран у шаблоні 3x3 - java, android, xml, view, imagebutton

Мені подобається розташувати екран у 3-х колоннах і 3-хрядки в моєму додатку Android. всі дев'ять квадратів завжди повинні бути однакового розміру. Кожен квадрат повинен мати можливість містити зображення або відео, яке не повинно зменшуватися.

У мене вже є повністю робоче рішення, але цевін просто працює на певному розмірі екрана, тому що я жорстко кодував атрибути layout_withd і layout_heigth. Я працював з Tablelayout, що містить три TableRows і кожен з яких містить три LinearLayouts.

Чи можете ви, будь ласка, надати мені пораду, як це правильно розпочати? Він має працювати на всіх пристроях.

Дякую за допомогу

Відповіді:

2 для відповіді № 1

Спробуйте це

<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<LinearLayout android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/linearLayout2" android:layout_weight="1">
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1"/>
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1"/>
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1"/>
</LinearLayout>

<LinearLayout android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/linearLayout" android:layout_weight="1">
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1"/>
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1"/>
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1"/>
</LinearLayout>

<LinearLayout android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/linearLayout2" android:layout_weight="1">
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1"/>
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1"/>
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>