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 als
Solution 1:
Use the xhdpi resources and try to set all the layouts at the runtime using the layout params according to the device.
or let the android decide what is best for the device create following folders
layout-large
layout-small
layout-sw600
layout-sw720
and similar folders to organize your layouts better
Solution 2:
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-densityin 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>
Post a Comment for "Need A Working Example Of Handling Large And Small Screens On Android"