I apologize in advance for asking this question, I know similar questions have already been asked hundreds of times, but despite the fact that I read the Android Screen Support guide several times, I still don't understand how to create a basic layout that fits several screen without being able to use proportional dimensions.
So basically, if I sum-up what this guide tells us to do:
RelativeLayout
or FrameLayout
instead of AbsoluteLayout
dp
dimensions instead of px
dimensions to get rid of the density difference problem.Ok. This makes sense.
Now, here are my questions (I apologize in advance for their silliness):
density groups
if I use Density Independent Pixels (dp)
dimensions?dp
dimensions?Thank you, and sorry again for going over this topic again...
You do not have to create different layouts. I mostly only use one layout for portrait and one for landscape mode leaving everything else to the system.
If you want to get 2 buttons of the same size just use
android:layout_width="fill_parent"
android:layout_weight="1"
for both buttons and put them into a linear layout container.
edit (complete code, will give two buttons side by side):
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal">
<Button
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/b1" android:onClick="btn1" />
<Button
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/b2" android:onClick="btn2" />
</LinearLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With