【问题标题】:Customize setting activity in android (preference)在 android 中自定义设置活动(首选项)
【发布时间】:2017-01-06 08:54:24
【问题描述】:

我在 android studio 中使用了设置活动模板(首选项),但我有这个布局。my XML

但我希望布局看起来像这样 new XML

我完成了用 Photoshop 创建顶部栏“帮助”,如何添加顶部栏“帮助”,就像我的自定义布局一样?谢谢。

这是我的代码(pref_headers.xml):

<header
    android:fragment="com.example.hp.refomandaapps.SettingsActivity$NotificationPreferenceFragment"
    android:icon="@drawable/ic_notifications_black_24dp"
    android:title="@string/pref_header_notifications" />

<header
    android:fragment="com.example.hp.refomandaapps.SettingsActivity$DataSyncPreferenceFragment"
    android:icon="@drawable/ic_sync_black_24dp"
    android:title="@string/pref_header_data_sync" />

【问题讨论】:

    标签: android xml settings preference


    【解决方案1】:

    在顶部添加这个。

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:background="#000">
    
    
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="Title"
        android:id="@+id/tv_title"
        android:textSize="8.5pt"
        android:textColor="@color/colorWhite"
        android:layout_centerHorizontal="true"/>
    
     </RelativeLayout>
    

    【讨论】:

    • 感谢您的回答,但我使用来自 android studio 的默认模板,该模板是由 R.xml.header 创建的布局,而不是由 R.layout.*example 创建的。所以我很困惑从 xml 文件夹修改布局
    • 创建你的自定义布局为什么要使用 Android stdio 的布局。
    • 因为使用 android studio 模板(设置首选项)更容易进行设置布局,但我无法修改布局。
    • 这就是我说的原因。你的设计很容易制作,所以让你自己的布局。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-13
    • 2011-10-05
    相关资源
    最近更新 更多