【发布时间】:2018-07-25 10:20:58
【问题描述】:
我创建了一个导航抽屉活动,发现它的内容页面在预览中看起来不同。
And this is the AVD appearance (it looks like a real device too).
XML 代码是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.xy.xy.HomePage">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="160sp"
android:layout_marginLeft="5sp"
android:layout_marginRight="5sp"
android:layout_marginTop="5sp">
<ImageView
android:id="@+id/TestMenuImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/app_name"
app:srcCompat="@drawable/bg1"
tools:scaleType="centerCrop" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
tools:background="@color/hbm_text_background">
<TextView
android:id="@+id/TestMenuName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5sp"
android:contentDescription="@string/app_name"
android:text="@string/test"
android:textColor="@color/white" />
</RelativeLayout>
<Button
android:id="@+id/TestMenuButton"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</LinearLayout>
你认为问题出在哪里?
【问题讨论】:
-
你在这两个地方都使用nexus 4吗??
-
尝试使用 fitXy 代替 centerCrop imageView..
-
不,我在 AVD 上使用 Galaxy Nexus,但我尝试了一个预览版,但遇到了同样的问题。 imgur.com/4LKgX7l
-
尝试删除 tools:context="com.xy.xy.HomePage" 然后刷新您的预览,看看它是否与设备上的结果匹配。
标签: android xml android-activity device preview