app:showAsAction 和android:showAsAction


app:showAsAction

它有三個可選項
1.always:總是顯示在界面上
2.never:不顯示在界面上,只讓出現在右邊的三個點中
3.ifRoom:如果有位置才顯示,不然就出現在右邊的三個點中

 

 

android:showAsAction

這個屬性可接受的值有:

1.alaways:這個值會使菜單項一直顯示在ActionBar上。

2.ifRoom:如果有足夠的空間,這個值會使菜單顯示在ActionBar上。

3.never:這個值菜單永遠不會出現在ActionBar是。

4.withText:這個值使菜單和它的圖標,菜單文本一起顯示。

 

When using the appcompat library, menu resources should refer to the showAsAction in the app: namespace, not the android: namespace.

Similarly, when not using the appcompat library, you should be using the android:showAsAction attribute.
I think the problem is that you are mixing Framework Activity and AppCompat menu. You should use AppCompatActivity with AppCompat Action bar and app:showAsAction;
or Activity with android:showAsAction.
public class MainActivity extends AppCompatActivity {//像這樣的AppCompatActivity 需要使用app:showAsAction
    ..........  
}

 

public class MainActivity extends Activity{ //像這樣的Activity 需要使用android:showAsAction
      .........  
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM