我尝试将两个按钮(它们上面的图像工作正常)安排在一起,并将它们水平居中.这就是我到目前为止所拥有的:
<LinearLayout android:orientation="horizontal" android:layout_below="@id/radioGroup"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center">
<Button
android:id="@+id/allow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/radioGroup"
android:layout_gravity="center_horizontal"
android:drawableLeft="@drawable/accept_btn"
android:text="Allow"/>
<Button
android:id="@+id/deny"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/allow"
android:layout_below="@id/radioGroup"
android:layout_gravity="center_horizontal"
android:drawableLeft="@drawable/block_btn"
android:text="Deny"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
不幸的是,它们仍然与左侧对齐.任何帮助表示赞赏!伊夫
编辑:
不幸的是,迄今为止没有任何评论或建议有效.这就是我尝试使用RelativeLayout提供简化的完整布局的原因:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
<TextView android:text="@+id/TextView01" android:id="@+id/TextView01"
android:layout_width="wrap_content" android:layout_height="wrap_content"/>
<Button
android:id="@+id/allow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/TextView01"
android:text="Allow"/>
<Button
android:id="@+id/deny"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/allow"
android:layout_alignTop="@id/allow"
android:text="Deny"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我已经尝试了LinearLayout和Button元素中的所有属性组合而没有运气.还有其他想法吗?
我有自己的TreeView控件,完全是OwnerDraw'n:
myTreeView.DrawMode = TreeViewDrawMode.OwnerDrawAll;
Run Code Online (Sandbox Code Playgroud)
我试图实现的是根据当前的资源管理器主题绘制打开/关闭的字形.特别是在Vista和Win7盒子上,我希望看到新的支架(黑色三角形)而不是加号/减号.我知道,对于非OwnerDraw'n TreeView,这可以通过以下方式实现:
myTreeView.HandleCreated += delegate(object sender, EventArgs args)
{
MyNativeMethods.SetWindowTheme(myTreeView.Handle, "explorer", null);
};
Run Code Online (Sandbox Code Playgroud)
我认为VisualStyleRenderer让我绘制主题感知的字形:
VisualStyleRenderer r = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened);
r.DrawBackground(e.Graphics, e.Bounds);
Run Code Online (Sandbox Code Playgroud)
不幸的是,上面的代码在所有情况下都会绘制减号.看起来VisualStyleRenderer不尊重主题设置.
有人可以对此有所了解吗?谢谢!