我将应用theme设置为NoActionBar,设置的页面在as预览于没问题,如图:
但是在虚拟机运行么就这样了:
布局代码如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme"
tools:context=".layout.UserFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="120dp"
android:background="@drawable/user_top">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_alignParentLeft="true"
android:orientation="vertical">
<TextView
android:id="@+id/uername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="40sp"
android:text="Mr.Alias"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="查看或编辑个人主页"
android:textColor="@color/white"
android:textSize="18sp"/>
</LinearLayout>
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_image"
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_margin="20dp"
android:layout_alignParentRight="true"
android:src="@drawable/slide_6"
app:civ_border_width="1dp"
app:civ_border_color="#000"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/rl_messageCenter"
android:background="@drawable/underline"
android:padding="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/iv1"
style="@style/userPartImage"
android:background="@drawable/ic_message"/>
<TextView
android:id="@+id/tv1"
style="@style/exploreText"
android:layout_toRightOf="@+id/iv1"
android:text="消息中心"/>
<ImageView
style="@style/exploreArrows"
android:background="@drawable/ic_arrows"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="20dp">
<RelativeLayout
android:id="@+id/rl_myAttention"
android:background="@drawable/underline"
android:padding="5dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv01"
style="@style/userPartImage"
android:background="@drawable/ic_attention"/>
<TextView
android:id="@+id/tv01"
style="@style/exploreText"
android:layout_toRightOf="@+id/iv01"
android:text="我的关注"/>
<ImageView
style="@style/exploreArrows"
android:background="@drawable/ic_arrows"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/rl_myCollection"
android:background="@drawable/underline"
android:padding="5dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv02"
style="@style/userPartImage"
android:background="@drawable/ic_collect"/>
<TextView
android:id="@+id/tv02"
style="@style/exploreText"
android:layout_toRightOf="@+id/iv02"
android:text="我的收藏"/>
<ImageView
style="@style/exploreArrows"
android:background="@drawable/ic_arrows"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="20dp">
<RelativeLayout
android:id="@+id/rl_expandThesaurus"
android:background="@drawable/underline"
android:padding="5dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv03"
style="@style/userPartImage"
android:background="@drawable/ic_expand"/>
<TextView
android:id="@+id/tv03"
style="@style/exploreText"
android:layout_toRightOf="@+id/iv03"
android:text="扩充词库和语音库"/>
<ImageView
style="@style/exploreArrows"
android:background="@drawable/ic_arrows"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/rl_setting"
android:background="@drawable/underline"
android:padding="5dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv04"
style="@style/userPartImage"
android:background="@drawable/ic_setting"/>
<TextView
android:id="@+id/tv04"
style="@style/exploreText"
android:layout_toRightOf="@+id/iv04"
android:text="设置"/>
<ImageView
style="@style/exploreArrows"
android:background="@drawable/ic_arrows"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/rl_satisfactionSurvey"
android:background="@drawable/underline"
android:padding="5dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv05"
style="@style/userPartImage"
android:background="@drawable/ic_searchsatisfaction"/>
<TextView
android:id="@+id/tv05"
style="@style/exploreText"
android:layout_toRightOf="@+id/iv05"
android:text="满意度调查"/>
<ImageView
style="@style/exploreArrows"
android:background="@drawable/ic_arrows"/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
style.xml:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:fitsSystemWindows">true</item>
<item name="android:listDivider">@drawable/divider</item>
</style>
<resources>