2016-05-26 52 views
0

你好,爲什麼我的活動中的這個酒吧是隱藏的? 這是我的截圖Android:如何顯示此欄並在工具欄中添加圖標?

enter image description here

如何顯示呢?並添加圖標和標題在工具欄中

這是我的活動users.xml中

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    xmlns:app="http://schemas.android.com/tools" 
    android:id="@+id/scrollView" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 
     <include 
      layout="@layout/toolbar" 
      android:id="@+id/tb"> 
     </include> 
      <android.support.v7.widget.CardView 
       android:id="@+id/cardview1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       card_view:cardBackgroundColor="@android:color/white" 
       card_view:cardCornerRadius="8dp" 
       card_view:cardElevation="20dp" 
       android:layout_marginTop="10dp" 
       android:layout_marginRight="10dp" 
       android:layout_marginLeft="10dp"> 
       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:orientation="vertical"> 
        <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="50dp" 
         android:gravity="center_vertical" 
         android:background="@color/lignt_blue" 
         android:paddingLeft="25dp"> 
    .... 

這是我的活動users.java

public class Users extends AppCompatActivity { 
    private TextView editName; 
    private ImageView imageView1; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.users); 
    Intent intent = getIntent(); 
    String ref2 = intent.getStringExtra("ref"); 
    Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar); 
    setSupportActionBar(myToolbar); 
     editName = (TextView) findViewById(R.id.editName); 
     imageView1= (ImageView)findViewById(R.id.imageView1); 
    } 

這是我toolbar.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.Toolbar 
    android:id="@+id/my_toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="?attr/actionBarSize" 
    android:background="?attr/colorPrimary" 
    android:elevation="4dp" 
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar" 
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" /> 
+0

您的狀態欄未被隱藏。它採用在color.xml或styles.xml中定義的Primarycolor的顏色。 –

+0

沒有我的顏色是藍色#3F51B5 with

+0

你可以張貼您的整個樣式xml。這可能對我有幫助 –

回答

0

從我研究過的,你必須完全全屏才能改變它。

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

使用下面的代碼,刪除或添加的狀態/電力杆的東西(它的名字我想不起來了):

要隱藏欄:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 

或者這展現酒吧:

getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 

如果這不是問題,那麼通過您的狀態欄的顏色的評論的外觀colorPrimaryDark

要解決這個問題,我會嘗試在styles.xml使用此:

<item name="android:colorPrimaryDark">@color/brand_color_dark</item> 

OR:

一下添加到styles.xml

<item name="colorPrimary">@color/yourColor</item> 
<item name="colorPrimaryDark">@color/yourColor</item> 

,然後刪除該代碼來自您的XML文件:

<item name="android:windowTranslucentStatus">true</item> 
<item name="android:fitsSystemWindows">true</item> 

嘗試所有這些方法,並讓我知道他們是否能解決您的問題。

相關問題