android文字滑动到标题,Android:如何创建带有滚动标题的对话框?

可以通过请求窗口功能CUSTOM_TITLE来完成Customizig窗口(以及对话框)的标题,这必须在setContentView之前完成.

因此,在您的Dialog / Activity子类onCreate()中,调用以下代码:

super.onCreate(savedInstance);

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); //

然后,在您的setContentView之后,执行以下操作:

setContentView(R.layout.main);

getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title); //

布局通常可以包含您想要的任何内容.

用于字幕文本控件.例如做这个:

布局/ custom_title.xml:

android:layout_width="fill_parent"

android:layout_height="fill_parent"

xmlns:android="http://schemas.android.com/apk/res/android"

>

android:layout_height="wrap_content"

android:layout_width="fill_parent"

android:text="This is a very very long text that will not fit into a caption regularly, so it will be displayed using marquee..."

android:lines="1"

android:focusable="true"

android:focusableInTouchMode="true"

android:scrollHorizontally="true"

android:marqueeRepeatLimit="marquee_forever"

android:ellipsize="marquee"

>

由于选取框功能的某些限制,必须使文本视图可聚焦,并且只有在聚焦时才滚动(最初应该是滚动的).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值