这是我的代码.
AlertDialog.Builder builder = new AlertDialog.Builder(this);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View vi = inflater.inflate(R.layout.group_dialog_layout,null);
builder.setView(vi);
TextView txtNewGroupEntry = (TextView) vi.findViewById(R.id.txtGroupRename);
if(isNew==true){
builder.setTitle("New Group");
txtNewGroupEntry.setText(R.string.new_group_instruction);
}
builder.setPositiveButton(R.string.ok_button, null);
builder.setNegativeButton(R.string.cancel_button, null);
AlertDialog dialog = builder.create();
dialog.show();
Button okButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
Run Code Online (Sandbox Code Playgroud)
我有一个带有添加按钮和取消按钮的警告对话框.我希望按钮的文本都是粗体和斜体.我该怎么做?
我试图通过样式扩大我的所有应用程序对话框按钮上的文本大小.以下代码将更改按钮背景颜色甚至文本大小写,但由于某种原因,textSize项目不符合:
<style name="MyAppTheme" parent="@android:style/Theme.Holo">
<item name="android:dialogTheme">@style/MyApp.Dialog</item>
<item name="android:alertDialogTheme">@style/MyApp.Dialog.Alert</item>
</style>
<style name="MyApp.Dialog" parent="@android:style/Theme.Holo.Dialog">
<item name="android:borderlessButtonStyle">@style/MyApp.BorderlessButton</item>
</style>
<style name="MyApp.Dialog.Alert" parent="@style/MyApp.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
</style>
<style name="MyApp.BorderlessButton" parent="@android:style/Widget.Holo.Button.Borderless">
<item name="android:textSize">50sp</item>
<item name="android:textAllCaps">true</item>
<item name="android:background">#800</item>
</style>
Run Code Online (Sandbox Code Playgroud)

为什么没有读取textSize?我需要做些什么来扩大它?
android android-layout android-theme android-dialog android-styles
我正在使用Android SDK制作游戏.一路上,我需要显示弹出/对话框,就像用户可以升级的任何其他游戏一样.我遇到的问题是对话框的大小.我正在使用RelativeLayout,我正在使用"wrap_content"将背景设置为我的图像.
对话框占用内部视图大小(或Android设置的默认对话框最小大小,以较大者为准)的问题不是背景图像.如果我使用fill_parent,那么它会拉伸它.我花了几个小时和几个小时旋转我,我似乎无法找到一个有效的方式,窗口的大小与背景图像的大小相匹配
有什么建议?这是一个非常常见的用例,必须有办法!谢谢
这是一些布局内容
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/popup"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageButton
android:id="@+id/ibCloseDialog"
android:background="@null"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/close" />
<Button
android:id="@+id/b1"
android:background="@drawable/blue_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/b2"
android:text="b1" />
<Button
android:id="@+id/b2"
android:background="@drawable/blue_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="b2" />
<Button
android:id="@+id/b3"
android:background="@drawable/blue_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/b2"
android:text="b2" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 我创建了一个自定义对话框,代码如下.问题是,对话框的高度变为wrap_content,即它与我在xml中提到的高度无关.我检查了其他问题,他们没有帮助我.
public class PointsDialogFragment extends DialogFragment{
private static final String TAG = PointsDialogFragment.class.getSimpleName();
public static PointsDialogFragment newInstance(){
PointsDialogFragment pdf = new PointsDialogFragment();
Bundle newBundle = new Bundle();
pdf.setArguments(newBundle);
return pdf;
}
private View mRoot;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
getDialog().requestWindowFeature(STYLE_NO_TITLE);
mRoot = inflater.inflate(R.layout.fragment_points_dialog, null);
return mRoot;
}
}
Run Code Online (Sandbox Code Playgroud)
和fragment_points_dialog.xml的xml是
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="313dp"
android:layout_width="fill_parent"
android:background="@color/green_gradient_start"
>
<RelativeLayout
android:layout_width="173dp"
android:layout_height="242dp"
android:background="@drawable/reward_box"
android:id="@+id/reward_box"
android:layout_alignParentLeft="true"
>
<TextView
android:layout_centerInParent="true"
style="@style/WallSectionHeading"
android:text="5"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="173dp"
android:layout_height="250dp"
android:background="@drawable/reward_mascot" …Run Code Online (Sandbox Code Playgroud) android android-layout android-dialog android-dialogfragment
我有对话框片段.我打算在活动和对话中使用这个片段.我重写onCreateDialog和onCreateView方法.这是编码.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.interval_time_popup, null);
setup(view, false);
return view;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
View view = getActivity().getLayoutInflater().inflate(R.layout.interval_time_popup, null);
builder.setTitle("Interval Time");
builder.setView(view);
setup(view, true);
builder.setPositiveButton("Set", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
listener.setOnIntervalTime(hourNp.getValue(), minNp.getValue());
dismiss();
}
});
builder.setNegativeButton("Cancel", new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dismiss();
}
});
return builder.create();
}
Run Code Online (Sandbox Code Playgroud)
我在活动类中使用这个片段.
SelectTimeIntervalDialogFragment fragment = new …Run Code Online (Sandbox Code Playgroud) android android-fragments android-dialog android-dialogfragment
在我的应用程序中,我希望显示一个始终可见,半透明的状态,但我很难弄清楚它是如何完成的.
Facebook Messenger和我见过的一些其他应用程序就是这样做的,所以我知道它是可能的.他们使用SYSTEM_ALERT_WINDOW权限来显示一个大致透明的活动或对话框'always-on-top'.
但我不明白的是他们如何制作它以便在按下后退或主页按钮时它们不会关闭?换句话说,他们似乎根本不像活动,但我不知道他们还能做什么?
这里的任何帮助将非常感谢:-)
如果我有一个将其主题设置为的活动Theme.Holo.Light.Dialog,它将扩展得很好.它几乎完全以纵向模式填充在手机屏幕上,但在横向模式下,它不会长时间不合理地伸展.例如,在Google的这张图片中,您可以看到对话框没有填满整个屏幕.

它不会崩溃以匹配标题的宽度,如果你有一个扩展Dialog类的类有你自己的Dialog构建会发生什么.
这是我的布局会发生的事情.

我需要将哪些属性应用于LinearLayout以使其扩展得相当漂亮?
我一直在互联网上搜索一个简单易用的Android文件选择器对话框,该对话框还可以选择多个文件并返回一个包含所有文件的uri或字符串数组.
目前我在github上使用aFileChooser,它比android-file-dialog更好.但是都没有解决传递多个文件的问题.
我只是一个中级Android开发人员,但我认为这将是专业人士不太难实现的.
我查看了aFileChooser的代码,我认为在文件项中添加一个复选框是可行的方法,但就代码而言,我一无所知,开发人员似乎在可预见的未来他不会真正开展工作
所以简而言之,我要求帮助,通过github或这里将选择多个文件选项添加到aFileChooser,或者可能建议我做一个更好的对话,做我想要的.
我正在研究AndroidRate库的Apple Style AlertDialog功能,无法解决 Android 9-10 API上的一些错误.
我的style.xml:
<?xml version="1.0" encoding="utf-8"?>
<!--
~ // Copyright 2018 Vorlonsoft LLC
~ //
~ // Licensed under The MIT License (MIT)
-->
<resources>
<!-- Base Apple and Modern types Rate Dialog theme. -->
<style name="RateDialogTransparentTheme">
<item name="android:background">@color/rateDialogColorTransparent</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:backgroundDimAmount">0.4</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowBackground">@color/rateDialogColorTransparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowTitleStyle">@null</item>
</style>
</resources> …Run Code Online (Sandbox Code Playgroud) 我试图显示一个带有match_parent的DialogFragment高度和宽度,但它发生在顶部,DialogFragment显示在StatusBar下面.
DialogFragment在底部,右侧,左侧和顶部应用了一些默认值.但顶部填充应从statusBar开始计数,而不是从总屏幕大小开始计算.
如何将DialogFragment设置为match_parent,但是在顶部,底部,右侧,左侧具有正常/默认填充?
android android-dialog android-windowmanager android-dialogfragment android-window