Fragment如何实现左右分屏显示的

随着手机不同尺寸的推出,加上平板市场的火热,很多软件开始做左侧导航,右侧详情,这样可以方便我们更加直观的看到详情。
例如这样:
这里写图片描述

下面就用简洁明了的代码来说怎样实现的吧!
直接上步骤

1.在AndroidManifest里面先把Activity设置成横屏显示
加粗这块放进去即可,当然不设置也没事哈
这句话:
android:screenOrientation=”landscape”

<activity android:name=".MainActivity"
            android:screenOrientation="landscape"
            >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

     <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

2.再去写布局啦
activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.holly.mytest4">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity"
            android:screenOrientation="landscape"
            >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

再写左侧的fragment布局,取名:left_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
   android:background="@android:color/white"
    android:orientation=
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值