android 開發隱藏標題欄的方法總結
1. 推薦!(因為現在工程都默認的為AppTheme)
在value/styles.xml里面添加自定義屬性
<resources xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Application theme. --> <style name="AppTheme" parent="AppBaseTheme"> <item name="android:windowNoTitle">true</item></resources>
2.
public class MainActivity extends Activity{ @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); // 隱藏標題欄 requestWindowFeature(Window.FEATURE_NO_TITLE); // 隱藏狀態欄 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); //一定要放在setContentView()之前! setContentView(R.layout.activity_main); }}3.
<!-- 同時隱藏狀態欄和標題欄 --><activity android:name="com.ysj.demo.MainActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter></activity>
4.打開項目文件AndroidManifest.xml ,打開Application選擇TAB頁,在頁面下方的Application Nodes中點選擇相應的類, 配置右側的Theme屬性。
在彈出選擇框中點選"system Resources",選擇Theme.NoTitleBar項目,然后重新打開頁面就行了
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
新聞熱點
疑難解答