2013-03-23 25 views
11

Trong giao diện đồ họa của bố cục, khi tôi chọn API 15 hoặc thấp hơn từ nút được hiển thị trong hình bên dưới, văn bản trong các nút được bao quanh trông rất ổn.Văn bản Nút Android không tập trung khi sử dụng API 17 để hiển thị

enter image description here

Khi tôi chọn API 17, văn bản được dời mặc dù mã xml là cùng. Việc thay đổi nút đệm không giúp ích gì.

enter image description here

Đây có phải là chỉ là một vấn đề với Eclipse hoặc là nó có thể là phiên bản mới của Android có thể thấy văn bản dời này?

Giải pháp khắc phục sự cố này là gì?

mã XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".HomeActivity" > 

<LinearLayout 
    android:id="@+id/linearLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:layout_margin="3dp" > 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="100dp" 
     android:src="@drawable/label" /> 
</LinearLayout> 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/linearLayout1" 
    android:layout_below="@+id/linearLayout1" 
    android:layout_marginTop="20dp" 
    android:text="@string/about_title" 
    android:textSize="20sp" /> 

<TextView 
    android:id="@+id/textView2" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/textView1" 
    android:layout_alignRight="@+id/linearLayout1" 
    android:layout_below="@+id/textView1" 
    android:layout_marginTop="5dp" 
    android:text="@string/temp" /> 

<LinearLayout 
    android:id="@+id/linearLayout2" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/textView2" 
    android:layout_alignRight="@+id/textView2" 
    android:layout_below="@+id/textView2" 
    android:layout_marginTop="20dp" 
    android:baselineAligned="false" > 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="@string/news" /> 

    <Button 
     android:id="@+id/button2" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="@string/tournaments" /> 

    <Button 
     android:id="@+id/button3" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="@string/results" /> 
</LinearLayout> 

Trả lời

10

android:gravity="center" không giúp

tôi khởi động lại nhật thực hai lần. Kỳ lạ là nó đã không giúp đỡ trong việc khởi động lại đầu tiên nhưng nó trông tốt sau khi thứ hai. Ngoài ra, nó hoạt động tốt trên thiết bị. Xin lỗi cho câu hỏi, tôi phải đợi trước khi đăng câu hỏi.

+1

tốt để nghe :) Đừng quên chấp nhận một trong những câu trả lời :) – Goddchen

+0

không thể chấp nhận câu trả lời của riêng trong vòng 2 ngày kể từ ngày đăng ... –

+0

Tôi chạy vào cùng một vấn đề. Cảm ơn! –

3

Không chắc chắn nếu phong cách mặc định cho nút thay đổi trong API17 ... có thể ...

Dù sao, thêm android:gravity="center" nên được sửa chữa này cho bạn .

+0

tôi đã thử rằng .. đã không hoạt động ... văn bản vẫn giống nhau –

+0

bạn đã thử chạy nó trong trình giả lập chưa? Tôi đã bắt gặp bản xem trước IDE làm những điều kỳ lạ trước khi điều đó không xảy ra khi thực sự chạy ứng dụng trên thiết bị/trình mô phỏng ... – Goddchen

+0

plz kiểm tra câu trả lời của tôi .. xin lỗi vì đã lãng phí thời gian ur vào câu hỏi ngu ngốc này! –

0

thêm android:gravity="center" nên được sửa chữa này cho bạn

2

tôi không biết tôi phải đối mặt với kiểm tra vấn đề này khởi động lại một nhật thực .. và kiểm tra ..

+0

được bỏ phiếu. tôi đã làm điều này nhưng nó đã giúp làm điều đó hai lần! thấy câu trả lời ur sau khi nó đã được cố định .. thnx! –

+0

ok không có vấn đề ... – SelvaMariappan

Các vấn đề liên quan