<RelativeLayout
android:id="@+id/contact_relMainHeader"
android:layout_width="match_parent"
android:layout_height="50dip"
android:background="#16A180"
android:padding="5dp" >
<ImageView
android:id="@+id/contact_btnMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:background="@drawable/scrol" />
<Button
android:id="@+id/contact_btnLogout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:background="@drawable/lock" />
<ImageView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginBottom="5dip"
android:layout_marginLeft="15dip"
android:layout_marginRight="15dip"
android:layout_marginTop="5dip"
android:layout_toLeftOf="@+id/contact_btnLogout"
android:background="@drawable/centertext"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
我需要创建像给定图像一样的标题。
但我无法设置我尝试过但不看弹出图像。
这是我的屏幕:
我已经尝试了很多,但我无法实现像给定图像那样的弹出
最佳答案
如果您确实想实现此目的,您的图像会被拉伸(stretch),因此请勿使用背景
值。相反,请使用 src
并且不要使用 Button
,而是使用 ImageView
。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/contact_relMainHeader"
android:layout_width="match_parent"
android:layout_height="50dip"
android:background="#16A180"
android:padding="5dp" >
<ImageView
android:id="@+id/contact_btnMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:src="@drawable/scrol" />
<ImageView
android:id="@+id/contact_btnLogout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip"
android:src="@drawable/lock" />
<ImageView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:gravity="center"
android:src="@drawable/centertext"
/>
</RelativeLayout>
关于android - 如何在android中制作标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23422754/