自定义Activity的标题栏

xiaoxiao2023-01-25  8

MyActivity.java requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.main); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title); TextView titleTV = (TextView)findViewById(R.id.title); titleTV.setText(R.string.app_name); title.xml <?xml version="1.0" encoding="UTF-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:layout_gravity="center" android:gravity="center" /></LinearLayout> 相关资源:Android项目中自定义顶部标题栏
转载请注明原文地址: https://www.6miu.com/read-4980767.html

最新回复(0)