user6750923
user6750923

Reputation: 479

Need a working Example of Handling large and small screens on Android

I tried a lot for handling multiple Tablet and handset screens on Android but could not get right way of doing this. In some cases I am getting errors and some does not work. I also posted Stack Question but did not receive satisfied result. I want to show a list and discription side by side on tablet screen whereas only list in mobile screen. Is there any good and easy way of doing this? I also tried to this but could not get the goal.

Upvotes: 0

Views: 93

Answers (1)

Rushi Ayyappa
Rushi Ayyappa

Reputation: 2858

yes you can do this. There is a way where you can select layout based on the device.

res/layout/my_layout.xml              // layout for normal screen size ("default")
res/layout-large/my_layout.xml        // layout for large screen size
res/layout-xlarge/my_layout.xml       // layout for extra-large screen size
res/layout-xlarge-land/my_layout.xml  // layout for extra-large in landscape orientation

res/drawable-mdpi/graphic.png         // bitmap for medium-density
res/drawable-hdpi/graphic.png         // bitmap for high-density
res/drawable-xhdpi/graphic.png        // bitmap for extra-high-density
res/drawable-xxhdpi/graphic.png       // bitmap for extra-extra-high-density

res/mipmap-mdpi/my_icon.png         // launcher icon for medium-density
res/mipmap-hdpi/my_icon.png         // launcher icon for high-density
res/mipmap-xhdpi/my_icon.png        // launcher icon for extra-high-density
res/mipmap-xxhdpi/my_icon.png       // launcher icon for extra-extra-high-density
res/mipmap-xxxhdpi/my_icon.png      // launcher icon for extra-extra-extra-high-density

in case of 10' tab create a layout in

res/layout-sw720dp/my_layout.xml

in case of 7' tab create a layout in

res/layout-sw600dp/my_layout.xml


 <?xml version="1.0" encoding="utf-8"?>

<TextView
    android:id="@+id/title_detailfragment"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/detail_fragment"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">
    <fragment
        android:name="com.example.fyp_awais.tab.MainActivity$MyListFragment"
        android:id="@+id/list_fragment"
        android:layout_height="match_parent"
        android:layout_width="0dp"
        android:layout_weight="1" />
    <fragment
        android:name="com.example.fyp_awais.tab.MainActivity$MyDetailFragment"
        android:id="@+id/detail_fragment"
        android:layout_height="match_parent"
        android:layout_width="0dp"
        android:layout_weight="1" />

</LinearLayout>

Upvotes: 0

Related Questions