我创建了一个如下所示的操作栏。
程序语言是RTL。我使用以下代码更改了它:
onCreate()
并在 getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setIcon(R.drawable.actionbar_icon);
getSupportActionBar().setTitle("سیکاس");
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(0xff378417));
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
中使用了以下代码:
Drawable
黄色图标为<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@drawable/ic_launcher"
android:gravity="left"
android:top="5dp"
android:left="8dp" />
</layer-list>
。
private void Form1_Load(object sender, EventArgs e)
{
List<Person> list = new List<Person>();
list.Add(new Person(20, true));
list.Add(new Person(25, false));
list.Add(new Person(30, true));
dgv.DataSource = list;
//Hide checkbox column
dgv.Columns["IsProgrammer"].Visible = false;
//Add represent text column
DataGridViewTextBoxColumn textColumn = new DataGridViewTextBoxColumn();
textColumn.Name = "Yes / No";
dgv.Columns.Add(textColumn);
//true/false -> yes/no
foreach (var row in dgv.Rows.Cast<DataGridViewRow>())
row.Cells["Yes / No"].Value = (bool)row.Cells["IsProgrammer"].Value ? "Yes" : "No";
}
private class Person
{
public int Age { get; set; }
public bool IsProgrammer { get; set; }
public Person(int i, bool b)
{
Age = i;
IsProgrammer = b;
}
}
如何让黄色图标显示在操作栏的左侧?
答案 0 :(得分:1)
为操作栏添加自定义布局
setSupportActionBar(toolbar);
LayoutInflater mInflater=LayoutInflater.from(context);
View mCustomView = mInflater.inflate(R.layout.toolbar_custom_view, null);
toolbar.addView(mCustomView);
答案 1 :(得分:0)
更改
android:gravity="left"
与
android:gravity="end"