需要一个在Android上处理大屏幕和小屏幕的有效示例 [英] Need a working Example of Handling large and small screens on Android

查看:81
本文介绍了需要一个在Android上处理大屏幕和小屏幕的有效示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为在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.

推荐答案

是的,您可以执行此操作.有一种方法可以根据设备选择布局.

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

如果使用10'标签,请在

in case of 10' tab create a layout in

res/layout-sw720dp/my_layout.xml

如果使用7'标签,请在

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>

这篇关于需要一个在Android上处理大屏幕和小屏幕的有效示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆