Reputation: 10777
I am trying to hide the android action bar, I tried the following in the manifest:
android:theme="@android:style/Theme.NoTitleBar"
and also tried the following in my activity's onCreate method:
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
getActionBar().hide();
setContentView(R.layout.viewpager);
Both work fine and the actionbar is invisible. But the problem is, I cannot use the space that the actionbar left after it disappeared. I mean, if I want to center a widget in the layout vertically, it counts for the space the action bar covers, and then centers the widget in the space left, and so it looks like not centered.Here is the xml file content:
<?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:background="@color/background"
android:gravity="center_vertical" >
<LinearLayout
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/imageview_create_db_first_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/data" />
<TextView
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal"
android:id="@+id/textview_create_database"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/create_database"
android:textSize="15sp"
android:textColor="@color/white_text"/>
</LinearLayout>
</RelativeLayout>
So can anyone help me with this?
Thanks
Upvotes: 0
Views: 822
Reputation: 970
You should either use the no title flag:
requestWindowFeature(Window.FEATURE_NO_TITLE);
Or create your theme and add:
<item name="android:windowNoTitle">true</item>
Upvotes: 1
Reputation: 10338
Your code is fine. I have used similar code in my project. I think the margin:top attribute in your imageview is making it appear below the center.
android:layout_marginTop="20dp"
So remove this line.
Upvotes: 0