Android– 更改对话框按钮位置

Android– 更改对话框按钮位置,第1张

概述是否可以将对话框按钮的位置更改为对话框本身的外部?像这样的东西(红色方块是按钮): 我知道我可以通过以下方式获取按钮:dialog.getButton(AlertDialog.BUTTON_NEGATIVE)但我在手册上找不到改变它的位置的方法.解决方法:<?xmlversion="1.0"encoding="utf-8"?><LinearLay

是否可以将对话框上按钮的位置更改为对话框本身的外部?像这样的东西(红色方块是按钮):
 

我知道我可以通过以下方式获取按钮:

 dialog.getbutton(AlertDialog.button_NEGATIVE)

但我在手册上找不到改变它的位置的方法.

解决方法:

<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:orIEntation="vertical"androID:layout_wIDth="match_parent"androID:layout_height="match_parent"androID:gravity="center"androID:padding="20dp"androID:background="#00000000"><linearLayout    androID:background="@drawable/border_background"    androID:layout_gravity="center"    androID:gravity="center"    androID:padding="20dp"    androID:layout_wIDth="match_parent"    androID:layout_height="200dp"    androID:orIEntation="vertical">    <TextVIEw        androID:layout_wIDth="250dp"        androID:layout_height="wrap_content"        androID:text="@string/update_app"        androID:textSize="18sp"        androID:textcolor="@color/white"        androID:layout_gravity="center_horizontal"        androID:gravity="center" /></linearLayout><button    androID:paddingleft="10dp"    androID:paddingRight="10dp"    androID:layout_margintop="20dp"    androID:background="#123456"    androID:layout_wIDth="wrap_content"    androID:layout_height="35dp"    androID:layout_gravity="center"    androID:gravity="center"    androID:textcolor="#ffffff"    androID:textSize="14sp"    androID:onClick="onUpdateClicked"    androID:text="button" />

而不是使用默认警报对话框,在这里制作类似我的布局的自定义布局.并按钮执行所需的 *** 作.

您可以调用n显示此布局而不会像这样膨胀.
编辑:1

 public voID showUpdateLayout() {    mParentVIEw = (VIEwGroup) findVIEwByID(androID.R.ID.content);    if (mParentVIEw != null) {        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);        mUpdateLayout = inflater.inflate(R.layout.upadte_layout, mParentVIEw, false);        mParentVIEw.addVIEw(mUpdateLayout);        if (mUpdateLayout != null) {            mUpdateLayout.setVisibility(VIEw.VISIBLE);        }    }

在ur public class(或Custom Aprent Activity)中编写此方法.当你需要提醒时调用这个方法.

总结

以上是内存溢出为你收集整理的Android – 更改对话框按钮位置全部内容,希望文章能够帮你解决Android – 更改对话框按钮位置所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1119181.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存