Android去标题和实现全屏

来源:互联网 发布:linux 禁用独显 编辑:程序博客网 时间:2024/06/10 19:15

<span style="font-family: Arial, Helvetica, sans-serif;">requestWindowFeature(Window.FEATURE_NO_TITLE);</span>


一、Android中取出标题栏的方法:

 1、使用Java代码:

requestWindowFeature(Window.FEATURE_NO_TITLE);

2、在Activity的配置是实现:

       <activity            android:name="com.ccsu.training.activity.MainActivity"            <span style="background-color: rgb(255, 0, 0);">android:theme="@android:style/Theme.NoTitleBar"</span>            android:label="@string/app_name">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>
<span style="font-family: Arial, Helvetica, sans-serif;">二、实现全屏的方法:</span>

 1、在JAVA代码中:

<span style="white-space:pre"></span>getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
2、在Activity的配置文件中实现

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

 3、将该应用全部Activity实现全屏,在Application中实现配置

<span style="white-space:pre"></span>application android:icon="@drawable/icon"         <span style="white-space:pre"></span>android:label="@string/app_name"        <span style="white-space:pre"></span>android:theme="@style/fullscreem"

注意:当使用JAVA代码实现全屏或者无标题栏时,代码需在setContentView之前,否则会报错。


Android实现空间居中的方式:

 <LinearLayout         android:id="@+id/main_middle_layout"        android:layout_width="match_parent"    android:layout_height="wrap_content"       <span style="background-color: rgb(255, 0, 0);"> android:layout_gravity="center_vertical|center_horizontal"    android:gravity="center_vertical|center_horizontal"</span>        >        <TextView     android:id="@+id/main_textview"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:textColor="#f00"    android:textSize="25sp"    android:text="@string/main_textview"    android:layout_gravity="center_vertical|center_horizontal"    android:gravity="center_vertical|center_horizontal"    /></LinearLayout>



0 0
原创粉丝点击