相关疑难解决方法(0)

为什么LayoutInflater会忽略我指定的layout_width和layout_height布局参数?

我很难让LayoutInflater按预期工作,其他人也是如此:如何使用layoutinflator在运行时添加视图?.

为什么LayoutInflater会忽略我指定的布局参数?例如,为什么我的资源XML中的值layout_widthlayout_height值不受尊重?

android android-layout

165
推荐指数
2
解决办法
10万
查看次数

使警报对话框背景透明

我正在Android Jelly Beans OS上创建一个警告对话框.一切都运作良好,但我想要的是,而不是警报对话框的黑色背景,我想要一个透明的背景.我在stackoverflow上阅读了很多文章和用户的问题,但没有一个能帮助我.

这是我的代码:

AlertDialog.Builder builder =  new AlertDialog.Builder(this, R.style.CustomAlertDialog);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog1, int which) {
            gActivityResult = REQUEST_PICK_CONTACT;
            onResume();
            return;
        } }); 
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog1, int which) {
            return;
        } }); 
    View view = getLayoutInflater().inflate(R.layout.alert_dialog, null);
    builder.setTitle(R.string.gender_age);
    builder.setInverseBackgroundForced(false);
    builder.setView (view);


    dialog = builder.create ();
Run Code Online (Sandbox Code Playgroud)

这是我的CustomAlertDialog,它在res/values/styles.xml中定义

<style name="CustomAlertDialog" parent="@android:style/Theme.Dialog">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    <item name="android:windowFrame">@null</item>
    <item name="android:windowIsFloating">true</item> 
    <item …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-alertdialog android-4.2-jelly-bean

3
推荐指数
1
解决办法
2万
查看次数