【问题标题】:how do I center a label i android? [duplicate]如何在我的 android 中居中标签? [复制]
【发布时间】:2011-05-18 13:55:51
【问题描述】:

可能重复:
How to align center the title or label in activity?

简单的问题,我制作了一个顶部带有标签的对话框。该标签出于某种原因将重力保留为默认值,我想将其更改为中心。标签在我的 AndroidManifest.xml 文件中定义为:

<b>activity</B> 
        android:name=".WelcomeDialog" 
        android:theme="@android:style/Theme.Dialog"
        android:label="@string/welcome_dialog_title"
        >

<b>/activity></B> 

我尝试输入 android:gravity="center" 但它不起作用,有什么提示如何解决这个问题吗?

提前谢谢!

【问题讨论】:

    标签: android


    【解决方案1】:

    只需将代码放在 setContentView(R.layout.new) 下...

    ((TextView)((FrameLayout)((LinearLayout)((ViewGroup) getWindow().getDecorView()).getChildAt(0)).getChildAt(0)).getChildAt(0)).setGravity(Gravity.CENTER);
    

    坦率地说,这段代码是从另一个 stackoverflow 问题复制而来的: How to align center the title or label in activity?

    我相信它可以帮助你交配!!!!

    ;)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-22
      • 1970-01-01
      • 1970-01-01
      • 2011-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多