开发者

how do I center a label i android? [duplicate]

开发者 https://www.devze.com 2023-03-07 05:07 出处:网络
This question already has answers here: 开发者_高级运维 Closed 11 years ago. Possible Duplicate: How to align center the title or label in activity?
This question already has answers here: 开发者_高级运维 Closed 11 years ago.

Possible Duplicate:

How to align center the title or label in activity?

Simple question, I have made a dialogbox with a label at the top. The label has for some reason gravity left as default, and I want to change it to center. The label is defined in my AndroidManifest.xml file as :

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

<b>/activity></B> 

I have tried to put android:gravity="center" but it is not working, any tips how to solve this issue?

Thx in advance!


just put the code under the setContentView(R.layout.new)...

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

To be very frank this code is copied from another stackoverflow question: How to align center the title or label in activity?

I am sure it can help you mate!!!!

;)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号