请看下面的代码
<?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="wrap_content"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/xxx_title"
android:layout_width="310dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/xxx_title"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#579bef"
android:textSize="50sp" />
<EditText
android:id="@+id/search"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="right"
android:layout_marginRight="30dp"
android:ems="10"
android:hint="@string/search_hint"
android:layout_marginTop="10dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
主页.java
import android.os.Bundle;
import android.app.ActionBar;
import android.app.Activity;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.widget.TextView;
public class Home extends Activity {
private TextView textView23;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
//Setting up the Action Bar
ActionBar actionBar = getActionBar(); //to support lower version too
actionBar.setDisplayShowHomeEnabled(false); // Remove icon
actionBar.setDisplayShowTitleEnabled(false); // Remove title text
actionBar.setDisplayShowCustomEnabled(true);
View customView=getLayoutInflater().inflate(R.layout.window_title, null);
actionBar.setCustomView(customView);
actionBar.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
textView23 = (TextView)findViewById(R.id.textView23);
textView23.setSelected(true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.home, menu);
return true;
}
}
这是我的操作栏的布局。我需要我的操作栏的高度与布局的内容高度相匹配,所以我尝试添加android:layout_height="wrap_content"
到布局中。但是,它并没有改变什么。
如何更改操作栏的大小?