首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >调整FastScroll警报对话框大小

调整FastScroll警报对话框大小
EN

Stack Overflow用户
提问于 2010-08-20 21:44:34
回答 2查看 810关注 0票数 5

我想对我的历史记录列表使用FastScroll,对部分使用日期,但是警告对话框(显示联系人中的字母)不能伸展到适合文本的大小(我想在那里显示月份和日期)。

我如何调整它的大小?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-09-21 23:17:45

我的解决方案。我们禁用了内置的快速滚动功能,并使用了this代码,只做了很小的改动。Variable mOverlaySize负责区段大小警报。

票数 1
EN

Stack Overflow用户

发布于 2010-09-06 02:00:59

它能像在AlertDialog类中使用setView一样简单吗?(以及对.xml的一些编辑)。首先,我从here上获取了有关setView的信息。

代码语言:javascript
复制
public void setView (View view, int viewSpacingLeft, int viewSpacingTop, int viewSpacingRight, int viewSpacingBottom)

Set the view to display in that dialog, specifying the spacing to appear around that view.    
Parameters:
view    The view to show in the content area of the dialog
viewSpacingLeft Extra space to appear to the left of view
viewSpacingTop  Extra space to appear above view
viewSpacingRight    Extra space to appear to the right of view
viewSpacingBottom   Extra space to appear below view

下面是一些使用setView的SDK示例代码(AlertDialogSamples.java)。

代码语言:javascript
复制
case DIALOG_TEXT_ENTRY:
            // This example shows how to add a custom layout to an AlertDialog
            LayoutInflater factory = LayoutInflater.from(this);
            final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null);
            return new AlertDialog.Builder(AlertDialogSamples.this)
                .setIcon(R.drawable.alert_dialog_icon)
                .setTitle(R.string.alert_dialog_text_entry)
                .setView(textEntryView)
                .setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {

                        /* User clicked OK so do some stuff */
                    }
                })
                .setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {

                        /* User clicked cancel so do some stuff */
                    }
                })
                .create();
        }
        return null;

最后,一些xml文件看起来像是在文本周围添加了边距(alert_dialog_text_entry.xml)。

代码语言:javascript
复制
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <TextView 
        android:id="@+id/username_view"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_marginLeft="20dip"
        android:layout_marginRight="20dip"
        android:text="@string/alert_dialog_username"
        android:gravity="left"
        android:textAppearance="?android:attr/textAppearanceMedium" />

希望能有所帮助。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3531398

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档