2017-02-27 113 views
0

我跟着this到Tablayout添加到我的活動使用Tablayout的Android應用程序讓應用程序在屏幕之外?

在同一個我已經改變了HomeActivity

public class HomeActivity extends Activitypublic class HomeActivity extends AppCompatActivity

現在我越來越喜歡這個

enter image description here

我想在操作欄中顯示選項菜單但是我得到兩個操作/應用程序欄佈局

以及完整的佈局缺少

  1. 所有我需要的操作欄和應用程序欄應結合
  2. 一些文本丟失我的意思是它甚至會在屏幕的一側。當我除去android:fitsSystemWindows="true"如果我保持這種每一件事情是好的。它在屏幕裏面,但是狀態欄旁邊的,但如果我刪除此底層應用程序的部分缺失

在我以前的應用程序,一切都很好,但由於Tablayout我我獲得了Issu的地段ES ... 任何一個可以建議我對這種...

更新

隨着用戶@ sanatchandravanshi我haved添加<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">還我已經加入

我已經加入此參考在我的代碼

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
setSupportActionBar(toolbar); 

現在,每一件事情是好的,但我的應用程序是重疊的畫面之外......

這是我在XML如果我把這個android:fitsSystemWindows="true"

我得到全面的應用程序屏幕,但首頁中隱藏狀態欄的旁邊這樣

enter image description here

但如果我刪除android:fitsSystemWindows="true"底側溢出屏幕之外....

像上面的圖片

任何一個可以建議我如何獲取應用程序以適應狀態欄,Appbar,Tablayout同一屏幕...

回答

1

請保持您的代碼

公共類HomeActivity擴展AppCompatActivity

僅低於行添加到您的style.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 

那麼最好的做法是使用Toolbar並根據需要自定義您的操作欄。

編輯:

用戶是這樣的:

public class DetailActivity extends AppCompatActivity { 
Toolbar mToolbar; 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_gallery_detail); 
    mToolbar = (Toolbar) findViewById(R.id.upload_gallery_app_bar); 
     setSupportActionBar(mToolbar); 
     getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE); 
     getSupportActionBar().setDisplayHomeAsUpEnabled(true);} 

創建菜單和使用菜單是這樣的:

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    getMenuInflater().inflate(R.menu.menu_gallery_detail, menu); 
    return true; 
}} 

更新

將一個LinearLayout中(而不是CoordinatorLayout ) ,如果我更改主題爲`安卓更改XML文件中像this

+0

如果我添加NoActionBar選項菜單丟失 – MLN

+0

請參見上面給出完整的代碼 –

+0

我回答這個主題,但它解決了我的問題,請檢查一次我更新的問題的一部分...你能幫助我在此我的佈局走出屏幕的....我已經給XML也 – MLN

0

你需要把manisfest沒有AppTheme.NoActionBar主題AppCompatActivity像這樣:

AndroidMenifest.xml

  <activity 
       android:name="view.activities.HomeActivity" 
       android:launchMode="singleTask" 
       android:screenOrientation="portrait" 
       //Change Theme to this 
       android:theme="@style/AppTheme.NoActionBar"> 
       <intent-filter> 
        <action android:name="android.intent.action.MAIN" /> 

        <category android:name="android.intent.category.LAUNCHER" /> 
       </intent-filter> 
      </activity> 

把這個主題放在風格

風格。XML

<style name="AppTheme.NoActionBar"> 
     <item name="windowActionBar">false</item> 
     <item name="windowNoTitle">true</item> 
    </style> 
+0

:主題=「@風格/ AppTheme.NoActionBar」'這裏選項菜單丟失......而應用的相同底部是隱藏...已經是我的應用程序只是所以我增加了一個新的光主題.. – MLN

相關問題