解决方案 »
- 【求助】为什么我的程序在android手机上无法响应音量按钮!?
- 请教一个利用Gson解析Json格式的问题
- 分享昨天IDC年会的一个演讲:云主机颠覆传统IDC模式
- 请问怎么将 ListView 每一行距离变小 默认的实在太大了
- BroadcastReceiver ?
- 跪求安卓蓝牙耳机连接以及播放音乐的代码
- 开机自动执行脚本问题请教
- 关于应用被GooglePlay暂停的问题。。。。。。
- include c++ support怎么没有了
- 关于绑定service后,activity和service通信更新ui的问题,困扰了很久
- 如何在系统拨号盘里,输入#号键
- Android 中WebView加载本地css和js
getSupportActionBar().setCustomView(LayoutInflater.from(this).inflate(R.layout.title, null));
其中title为自定义的布局文件。
getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(false);
这几个属性
还有我的只能ActionBar actionBar = this.getActionBar(); 不能getSupportActionBar() 对功能有没有什么影响
还有我的只能ActionBar actionBar = this.getActionBar(); 不能getSupportActionBar() 对功能有没有什么影响
第一个问题,我写的是R.layout.title,当然是定义在layout下;
第二个问题,getSupportActionBar()是因为我使用一个开源库,用来兼容低版本的手机,你使用getActionBar()是没有问题的,就是3.0以下版本是不兼容的。
还有我的只能ActionBar actionBar = this.getActionBar(); 不能getSupportActionBar() 对功能有没有什么影响
第一个问题,我写的是R.layout.title,当然是定义在layout下;
第二个问题,getSupportActionBar()是因为我使用一个开源库,用来兼容低版本的手机,你使用getActionBar()是没有问题的,就是3.0以下版本是不兼容的。
谢谢
我的布局文件这样写的,但不知道为什么还是不能居中显示
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" > <TextView
android:id="@+id/about_actionbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="关于"
android:textSize="18sp" /></RelativeLayout>
还有我的只能ActionBar actionBar = this.getActionBar(); 不能getSupportActionBar() 对功能有没有什么影响
第一个问题,我写的是R.layout.title,当然是定义在layout下;
第二个问题,getSupportActionBar()是因为我使用一个开源库,用来兼容低版本的手机,你使用getActionBar()是没有问题的,就是3.0以下版本是不兼容的。
Activity中的代码
super.onCreate(savedInstanceState);
ActionBar actionBar = this.getActionBar();
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setIcon(R.drawable.icon_back_btn_normal);
setContentView(R.layout.about);
/**
* actionBar添加自定义view
*/
View actionbarLayout = LayoutInflater.from(this).inflate(R.layout.about_actionbar, null);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(actionbarLayout);
还有我的只能ActionBar actionBar = this.getActionBar(); 不能getSupportActionBar() 对功能有没有什么影响
第一个问题,我写的是R.layout.title,当然是定义在layout下;
第二个问题,getSupportActionBar()是因为我使用一个开源库,用来兼容低版本的手机,你使用getActionBar()是没有问题的,就是3.0以下版本是不兼容的。
谢谢
我的布局文件这样写的,但不知道为什么还是不能居中显示
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" > <TextView
android:id="@+id/about_actionbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="关于"
android:textSize="18sp" /></RelativeLayout>
android:gravity="center"加上这句
还有我的只能ActionBar actionBar = this.getActionBar(); 不能getSupportActionBar() 对功能有没有什么影响
第一个问题,我写的是R.layout.title,当然是定义在layout下;
第二个问题,getSupportActionBar()是因为我使用一个开源库,用来兼容低版本的手机,你使用getActionBar()是没有问题的,就是3.0以下版本是不兼容的。
谢谢
我的布局文件这样写的,但不知道为什么还是不能居中显示
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" > <TextView
android:id="@+id/about_actionbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="关于"
android:textSize="18sp" /></RelativeLayout>
android:gravity="center"加上这句在RelativeLayout里加了android:layout_gravity="center"
在TextView里加了android:gravity="center"都没用
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center_vertical"
android:background="@color/maincolor"> <ImageButton
android:id="@+id/arClose"
android:layout_width="50dp"
android:layout_height="44dp"
android:src="@drawable/icon_back"
android:onClick="onClick"
android:background="@null" /> <TextView
android:id="@+id/arTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/white"
android:text="Title"
android:gravity="center"
android:textSize="16sp"
/>
</LinearLayout>