android - 如何在android中制作标题

标签 android

<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>

我需要创建像给定图像一样的标题。

enter image description here

但我无法设置我尝试过但不看弹出图像。

这是我的屏幕:

enter image description here

我已经尝试了很多,但我无法实现像给定图像那样的弹出

最佳答案

如果您确实想实现此目的,您的图像会被拉伸(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/

相关文章:

java - 使用折线选项在 map 上发生位置更改故障

android - 在 Android 上向自己发送短信

android - 关于删除级联android 2.2

android - 渲染失败,已知错误 FloatingActionButton

android-view - 带有wrap_content的View的默认宽度和高度

Android Speech to Text - 离线持续识别

android - 我如何知道 Android 项目是用哪个 IDE 制作的?

java - 如何将整个 View (水平和垂直滚动)保存为图像或pdf?

android - 迁移到 AndroidX android :button is not respected for API below Lollipop 后

javascript - 如何从 android fragment 调用 javascript 函数?