0
我正在开发Android智能手表应用程序。初始屏幕显示正常。但是,当我进入下一个屏幕时,上面的部分会弹出项目名称,就像这样。在下图中,Watch是项目的名称。Android Wear:布局在仿真器中无法正确显示
我想看到整个屏幕,而不是白色的空间,包含项目的名称。有谁知道如何解决它,为什么出现?
我的XML文件是
<?xml version="1.0" encoding="utf-8"?>
<android.support.wear.widget.BoxInsetLayout 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"
tools:deviceIds="wear">
<LinearLayout
android:id="@+id/mainContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/black"
android:weightSum="1"
tools:ignore="UselessParent"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true">
<LinearLayout
android:id="@+id/sign_up_top_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:layout_marginTop="15dp">
<TextView
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="5dp"
android:textAlignment="center"
android:textSize="18sp"
android:text="@string/text"
android:background="@color/black"
android:textColor="@color/white"
android:fontFamily="Century-Gothic.ttf" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="18dp"
android:layout_height="19dp"
android:layout_toRightOf="@+id/text"
android:src="@drawable/fingerprint" />
</LinearLayout>
<Button
android:layout_marginTop="10dp"
android:id="@+id/button"
android:background ="@drawable/roundedbutton"
android:text="@string/button_text"
android:layout_width="108dp"
android:textAlignment="center"
android:drawablePadding="20dp"
android:layout_gravity="center"
android:textColor="@color/white"
android:layout_height="75dp"
android:layout_weight="0.34" />
</LinearLayout>
</android.support.wear.widget.BoxInsetLayout>
你对你的活动使用什么主题?你可能需要一个“NoTitleBar”。 – TofferJ
我使用的是Theme.AppCompat.Light。 –
基于此[线程](https://stackoverflow.com/questions/25953614/round-android-wear-emulator-is-using-rect-layouts),有很多问题与膨胀布局是不正确的使用'WatchViewStub'。一个常见的问题是当你注册一个监听器的监听器,这样你可以检查它是否在你的'onApplyWindowInsets'处理程序中是圆形或方形的。 其他参考:https://stackoverflow.com/questions/28754782/android-wear-round-emulator-inflating-square-layout – abielita