This is my first post here. I just learned Android programming and came up with this problem. I searched a bit and found some solutions, but couldn't get my code to work. So I want to know which part of my code or implementation is incorrect.
So, the problem is that I want to make a layout that will remain the same proportion on different screen sizes and orientations. Here is my code:
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:baselineAligned="false" android:orientation="vertical"> <LinearLayout android:layout_width="fill_parent" android:layout_height="150dp" > <TextView android:layout_weight="1" android:layout_width="0dp" android:layout_height="fill_parent" android:gravity="left" android:id="@+id/textView1"/> <TextView android:layout_weight="1" android:layout_width="0dp" android:layout_height="fill_parent" android:gravity="right" android:id="@+id/textView2"/> </LinearLayout> <LinearLayout android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_weight="1" android:layout_width="0dp" android:layout_height="fill_parent" android:id="@+id/textView3"/> </LinearLayout> <LinearLayout android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_weight="1" android:layout_width="0dp" android:layout_height="fill_parent" android:gravity="left" android:id="@+id/textView4"/> <TextView android:layout_weight="1" android:layout_width="0dp" android:layout_height="fill_parent" android:gravity="center" android:id="@+id/textView5"/> <TextView android:layout_weight="1" android:layout_width="0dp" android:layout_height="fill_parent" android:gravity="right" android:id="@+id/textView6"/> </LinearLayout> <SeekBar android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/seekBar" android:max="255"/> </LinearLayout>
I canβt post the screenshot at the moment, because he said: "You need at least 10 reputation to send images."
So, I want to divide the screen into 3 parts vertically and divide the upper part by 2 horizontally, and the lower part by 3 horizontally and keep my proportion regardless of screen size, resolution and orientation.
The only part that didn't work was the top block, in the code I set for it, android:layout_height="150dp" , because the layout is somehow broken if I set them to android:layout_height="fill_parent" . But this does not make the proportion proportional if I change the orientation. Any help would be appreciated.
Thanks.
source share