android+自定义alertdialog,Android:如何自定义AlertDialog,Dialog an Spinner标题

好吧,我几乎已经解决了这个问题(我正在回答我自己的问题,因为它可能会帮助其他人解决与我相同的问题).

问题仍然存在于纺纱厂,DatePickers等.

对于AlertDialogs,我做这样的事情:

AlertDialog.Builder builder = new AlertDialog.Builder(MyActivity.this, AlertDialog.THEME_HOLO_LIGHT);

//Then I do what I need with the builder (except for setTitle();

LayoutInflater inflater = getLayoutInflater();

View view=inflater.inflate(R.layout.dialog_custom_title, null);

TextView title = (TextView)view.findViewById(R.id.myTitle);

title.setText("Title I want to show");

builder.setCustomTitle(view);

AlertDialog alert = builder.create();

alert.show();

dialog_custom_titile.xml:

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="#044592" >

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

android:id="@+id/myTitle"

android:layout_width="fill_parent"

android:textSize="20dp"

android:layout_height="70dp"

android:layout_marginLeft="25dp"

android:paddingTop="22dp"

android:textColor="@android:color/white"

android:textStyle="bold" />

对于我想看起来像Dialogs的活动,我喜欢这样:

我在Manifest.xml中声明它们如下:

android:name="com.aveschini.AnotherActivity"

android:screenOrientation="portrait"

android:label="My Dialog"

android:theme="@style/MyDialog"

android:windowSoftInputMode="adjustPan" />

然后,在res / values / styles.xml文件中我喜欢这样:

@style/DialogWindowTitle

@style/TextAppearance.DialogWindowTitle

#044592

@android:color/white

bold

20sp

我仍然在标题和身体之间得到浅蓝色的分隔线……仍在努力.

如前所述,我仍然不知道如何处理Spinners,DatePicker等…

这就是结果:

AlertDialog:

和一个带有对话框外观的Activity:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值