AppCompatActivity和Activity主題問題
阿新 • • 發佈:2019-01-04
AppCompatActivity和Activity的主題設定問題
想要這些活動沒有標題欄,
那麼就必須在manifest.xml檔案中設定Application的主題為:
android:theme="@android:style/Theme.NoTitleBar"
然後在需要標題欄的活動中設定自己需要的標題欄
然而AppCompatActivity這個狗比東西非要標題欄才不會出錯,那麼就需要在oncreate()中設定它是否顯示標題欄
在manifest.xml中設定標題欄,
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:name="com.csda.App" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar">
<activity android:name="com.csda.videos.VideoPlayActivity" android:configChanges="orientation|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation" android:theme="@style/Theme.AppCompat" android:screenOrientation="portrait" >
然後再oncreate()中隱藏:
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_videoplay);
getSupportActionBar().hide();
而在ACTIVITY中不用考慮,直接設定沒有標題欄就可以了:
<activity
android :name="com.csda.teachinglib.searchActivity"
android:theme="@android:style/Theme.NoTitleBar" />