gpt4 book ai didi

android - 如何在android中自定义Header

转载 作者:行者123 更新时间:2023-11-30 03:28:32 26 4
gpt4 key购买 nike

我想在我的 Activity 标题中显示以下图片:

enter image description here图片只有黑色部分。右边部分应该是页眉背景。 header 和 body 之间的分隔线应该被移除。

我怎样才能做到这一点?

我需要的总变化:

1. Remove the divider between header and body
2. Change the background color of header to blue
3. Set an background image on the left side of the header

最佳答案

如果您不需要使用任何选项菜单或任何其他 actionBarSherlock 功能,则不需要此库。您可以将任何主题与 NoTitleBar 一起使用并创建自定义 RelativeLayout 以创建页眉。

styles.xml:

<style name="AppTheme" parent="android:Theme.Light.NoTitleBar">
<!--Anything -->
</style>

您的 layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<RelativeLayout android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="50dip"
android:background="#6ccff6">

<ImageView
android:id="@+id/logo"
android:adjustViewBounds="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/abs_bg" />

<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:textColor="@android:color/white"
android:text="July 25"
android:textAppearance="?android:attr/textAppearanceMedium" />

</RelativeLayout>
<!-- Put any other layout/view here -->

</LinearLayout>

关于android - 如何在android中自定义Header,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17845894/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com