【发布时间】:2013-10-03 10:53:05
【问题描述】:
我正在尝试更改ActionBar的高度,我使用的代码如下所示
MainActivity:
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
View view = View.inflate(getApplicationContext(),
R.layout.actionbarview, null);
actionBar.setCustomView(view);
}
}
值/样式.xml:
<style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light">
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<!-- general styles for the action bar -->
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar">
<item name="actionBarSize">700dp</item>
</style>
Values-v11/styles.xml
<style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<!-- general styles for the action bar -->
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar">
<item name="android:actionBarSize">700dp</item>
</style>
actionbarview.xml
<?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"
android:layout_gravity="fill_horizontal"
android:background="#555333"
android:orientation="horizontal" >
<Button
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Title mswg" />
<Button
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</RelativeLayout>`
问题不是高度不变。我的目标sdk是17。
提前致谢!
【问题讨论】:
-
actionbarview布局的post code
标签: android android-layout android-actionbar