我得到了以下代码,由于某种原因,布局从顶部剪切。我没有指定任何边距或填充或任何东西,所以我很困惑为什么它这样做
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:text="Login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="login" />
<Button
android:text="User information"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="userInfo" />
</LinearLayout>
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sample_main);
}
Style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="@style/Theme.Leanback"></style>
</resources>
Theme.xml
<resources>
<style name="Theme.Example.Leanback" parent="Theme.Leanback">
<item name="android:windowEnterTransition">@android:transition/fade</item>
<item name="android:windowExitTransition">@android:transition/fade</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowContentTransitions">true</item>
<item name="android:colorPrimary">@color/search_opaque</item>
</style>
</resources>
答案 0 :(得分:1)
很可能是因为您正在使用Leanback主题。你在为电视开发吗?