Iñi*_*igo 1 android android-widget android-layout android-alertdialog
我正在给AlertDialog充气让用户发送评论.相当简单.但是我得到了这个Lint警告:
布局使用错误的按钮顺序API> = 14:创建一个相反顺序的layout-v14/chat_comment_dialog.xml文件:取消按钮应该在左边(是"@ string/send | Cancel",应该是"取消| @"字符串/发送")
所以,是的,这是解决方案,为API> = 14创建一个特定的布局并反转顺序.但是....真的吗?这真的是官方的建议吗?在某些设备中设置一个订单而在其他设备中设置不同的订单?作为用户,我会感到非常困惑.我是否应该忽略这个Lint建议,或者以其他方式,对一组设备遵循这种新模式(我认为相当混乱)
无论如何,这是布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp" >
<EditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
android:singleLine="true" />
<EditText
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="180dp"
android:gravity="top|left"
android:hint="@string/review" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingRight="4dp"
android:text="@string/send"
android:textSize="18sp" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="4dp"
android:text="@android:string/cancel"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
顺便说一下,我必须在XML中而不是在AlertDialog.Builder中膨胀按钮(也许这样按钮会自动自行排序),因为你设置为Builder的deafult按钮的任何onClickListener都会忽略对话框,而我必须避免这种行为来自己控制Dialog.
如果您计划定位API级别> 14,那么您一定要遵循设计规范.对对话框的布局进行了更改以提高可用性.
作为用户,您不会感到困惑,因为您只在单个API级别使用单个设备.什么是当开发人员创建非标准用户界面的混乱是.不遵守标准将导致沮丧和困惑.例如,如果用户手机上的所有其他应用程序(API级别> 14)使用正确的按钮顺序创建标准对话框,并且您的应用程序按钮顺序错误,则会导致用户点击取消而不是发送,反之亦然.当然这会使用户感到困惑和烦恼.
检查设备上的API级别并提供适当的布局确实没有那么多额外的工作.如果你很好地设计你的应用程序,它不应该需要多行代码.
| 归档时间: |
|
| 查看次数: |
2923 次 |
| 最近记录: |