[ Android.Activity Title bar 제거 ]
1. 정의
- Android App의 Title bar제거
2. Title bar 화면
- 왼쪽 화면은 Title bar가 존재
- 오른쪽 화면은 Title bar가 제거된 상태
3. Title bar 제거 방법 1
- 기본 Activity에
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
이 문장을 삽입한다.
반드시 setContentView()보다 먼저 기술해야 됨
|
public class UserActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState); setContentView(R.layout.activity_user); } } |
- java단에서 'Activity'를 상속받은 경우에는 다음을 사용
requestWindowFeature(Window.FEATURE_NO_TITLE);
- java단에서 'AppCompatActivity'를 상속받은 경우에는 다음을 사용
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
4. Title bar 제거 방법 2
1. Menifest 파일에 다음 tag 등록
- android:theme="@style/Theme.AppCompat.NoActionBar"
2. Application 전체에서 제거하려면
|
<application android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:allowBackup="true" android:supportsRtl="true" android:theme="@style/Theme.AppCompat.NoActionBar"> <activity android:name=".user.UserActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> |
3. Activity element만 제거하려면
|
<application android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:allowBackup="true" android:supportsRtl="true"> <activity android:theme="@style/Theme.AppCompat.NoActionBar" android:name=".user.UserActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> |