gpt4 book ai didi

java - Android TV Fragment(主 fragment )以垂直方向出现?

转载 作者:行者123 更新时间:2023-12-02 01:46:22 27 4
gpt4 key购买 nike

运行代码后,我的屏幕变成垂直方向,为什么?

这是我的主要 fragment (XML)----

我希望所有内容都以横向模式显示,因为它通常显示在电视上..

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_browse_fragment"
android:name="com.amriksingpadam.my_androidtv.MainFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:deviceIds="tv"
tools:ignore="MergeRootFrame" />

我找不到答案,请帮忙?

主要 fragment (Java)--

public class MainFragment extends BrowseFragment {
private static final String TAG = MainFragment.class.getSimpleName();

public void onActivityCreated(Bundle savedInstanceState){
Log.i(TAG,"On Activity Created!!");
super.onActivityCreated(savedInstanceState);
setupUIElements();
}

public void setupUIElements(){
setTitle("BOB TV");
}

}

最佳答案

在你的 list 中..

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com......">

<uses-permission .... />

<uses-feature
android:name="android.hardware.touchscreen"
android:required="false"/>
<uses-feature
android:name="android.software.leanback"
android:required="true"/>

<application
android:name="..."
android:allowBackup="true"
android:icon="@drawable/banner" . <--- You need this
android:label="@string/app_name"
android:theme="@style/Theme.Leanback"> . <--- You need this

<activity
android:name=".ui.main.MainActivity"
android:banner="@drawable/banner" <--- You need this
android:icon="@drawable/banner"
android:label="@string/app_name"
android:logo="@drawable/banner"
android:screenOrientation="landscape"> <--- You need this
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/> <--- You need this
</intent-filter>
</activity>

</application>

</manifest>

关于java - Android TV Fragment(主 fragment )以垂直方向出现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57452061/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com