【发布时间】:2014-08-13 12:14:44
【问题描述】:
借助http://www.learn2crack.com/2014/06/android-sliding-navigation-drawer-example.html
我设法让我的导航抽屉正常工作。我还在我的抽屉中添加了一个标题。在我的标题中,我有一个 Imageview,两个 TextView
数据显示正常,但由于某种原因,每部手机的用户界面都不同。图像被剪切或背景图像过大。
这是我测试过的 Galaxy Nexus 和 Nexus 5 的屏幕截图:
Nexus 5
银河系
这是标头 XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearTotalLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/backgroundforprofile"
android:baselineAligned="false"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/LinearLayoutforImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".30"
android:padding="10dp" >
<ImageView
android:id="@+id/imageforprofile"
android:layout_width="45dp"
android:layout_height="45dp"
android:src="@drawable/profilepic" />
</LinearLayout>
<LinearLayout
android:id="@+id/LinearLayoutforText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center"
android:layout_weight=".70"
android:orientation="vertical" >
<TextView
android:id="@+id/textforprofile"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left"
android:text="Joe David"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="@+id/textforprofileemail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left"
android:text="JoeDavidJoeDavi@joedavidjoedavid.com"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
有人可以帮我解决这个问题吗?
谢谢!
更新
根据@Rohan Pawar 和@westito 的建议,我将布局更改为相对 ImageView 没有被剪切并且文本正常输出,但背景图像在 Galaxy Nexus 和 Nexus 5 中仍然存在差异。请参阅我的截图如下。
银河系
Nexus 5
这是我的 XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearTotalLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/backgroundforprofile"
android:baselineAligned="false"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageforprofile"
android:layout_width="45dp"
android:layout_height="45dp"
android:paddingLeft="5dp"
android:paddingTop="10dp"
android:src="@drawable/profilepic" />
<TextView
android:id="@+id/textforprofile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/imageforprofile"
android:gravity="left"
android:paddingLeft="5dp"
android:paddingTop="10dp"
android:text="Dushyant Prabhu"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<TextView
android:id="@+id/textforprofileemail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textforprofile"
android:layout_toRightOf="@+id/imageforprofile"
android:gravity="left"
android:paddingLeft="5dp"
android:text="developer@sybershocknetworks.com"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</RelativeLayout>
【问题讨论】:
-
尝试使用相对布局
-
@RohanPawar:我尝试了相对布局,文本格式现在很完美,但每部手机的背景图像不同。我什至改变了相对布局的高度我没有看到任何区别?请检查我更新的问题
-
你的背景图片的分辨率是多少?
-
@RohanPawar: 1600 * 900。当宽度正常出现时,为什么不提高高度?
-
尝试 android:layout_height="match_parent" 到主布局
标签: android android-layout android-linearlayout