Issue
I have checked my layout an looks correctly, except 1 device landscape mode, which I would like to fix it.
Supporting multiple screens looks outdated.
600dp: a 7” tablet (600x1024 mdpi).
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
mdpi Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)
hdpi Resources for high-density (hdpi) screens (~240dpi).
My device is a 7" tablet with 800 x 1280 resolution: SM T235 has 216 dpi
I am wondering how could I fix his layout dimensions in landscape mode with less impact to others.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:background="@drawable/side_nav_bar"
android:gravity="bottom"
android:orientation="horizontal"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/top_left" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:text="Tel: "
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="123456789" />
</LinearLayout>
The imageView should be closer to left margin and the TextView with "Tel:" should be closer to image. But only in landscape mode and at this device. I have other device to test: 10" same resolution , and should not affect that.
I think the @dimen/activity_horizontal_margin
needs to be changed in /res/values/dimens.xml
by adding some suffixes to values
folder.
I have generated the values-v21
and values-w820dp
EDIT: The generated file at android Studio: res/values-w820dp/dimens.xml
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
I have no idea why takes values from values-w820dp since my width is less than 820. I just needed to append the -land
Solution
You may have overlooked tvdpi
qualifier of the page.
So you can use a specific dimens.xml as:
/res/values-land-tvdpi/dimens.xml
EDIT
When you use multiple qualifiers, order of these qualifiers should be the one of in the table2. See: Qualifier Rules.
Answered By - hata
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.