Tôi gặp sự cố rất lạ với bố cục. Nó trông giống như được thiết kế trong trình soạn thảo XML eclipse và trong thiên hà Samsung của tôi nhưng nó bị rối tung trong điện thoại cũ xperia mini x10 của tôi. Tôi chỉ có thể giả định rằng điều này sẽ xảy ra trong các thiết bị khác.android - bố cục có vẻ lộn xộn trong một số thiết bị
Nếu ai đó có thể giúp khắc phục điều này, tôi sẽ biết ơn.
Dưới đây là hai ảnh chụp màn hình và mã XML.
nó trông như thế trong trình soạn thảo bố trí nhật thực và trong thiên hà của Samsung của tôi S4 nhỏ
nó trông như thế trong Sony Xperia X10 Mini
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:gravity="center"
android:layout_height="wrap_content" >
<FrameLayout
android:layout_marginTop="7dp"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<View android:layout_marginTop="19dp" android:layout_marginLeft="19dp" android:layout_height="249dp" android:layout_width="2dp" android:background="#B2CFEF"/>
<View android:layout_marginTop="19dp" android:layout_marginLeft="189dp" android:layout_height="249dp" android:layout_width="2dp" android:background="#B2CFEF"/>
<View android:layout_marginTop="18dp" android:layout_marginLeft="20dp" android:layout_height="2dp" android:layout_width="170dp" android:background="#B2CFEF"/>
<View android:layout_marginTop="267dp" android:layout_marginLeft="19dp" android:layout_height="2dp" android:layout_width="171dp" android:background="#B2CFEF"/>
<ImageView style="@style/ta_img" android:id="@+id/ta_lu" android:layout_marginTop="52dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_lc" android:layout_marginTop="124dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_ld" android:layout_marginTop="197dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_ru" android:layout_marginLeft="170dp" android:layout_marginTop="52dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_rc" android:layout_marginLeft="170dp" android:layout_marginTop="124dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_rd" android:layout_marginLeft="170dp" android:layout_marginTop="197dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_tl" android:layout_marginLeft="37dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_tc" android:layout_marginLeft="84dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_tr" android:layout_marginLeft="132dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_bl" android:layout_marginLeft="37dp" android:layout_marginTop="249dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_bc" android:layout_marginLeft="84dp" android:layout_marginTop="249dp" />
<ImageView style="@style/ta_img" android:id="@+id/ta_br" android:layout_marginLeft="132dp" android:layout_marginTop="249dp" />
</FrameLayout>
</LinearLayout>
và đây là phong cách của ImageViews
<style name="ta_img" >
<item name="android:layout_width">40dp</item>
<item name="android:layout_height">40dp</item>
<item name="android:clickable">true</item>
<item name="android:src">@drawable/ta</item>
</style>
Bất kỳ ý tưởng nào ???
EDIT: Tôi đã chia tất cả giá trị dp cho 2 để xem liệu sự cố là tôi đã sử dụng giá trị dp cao hay chưa. Đây là kết quả có cả hai phiên bản cùng một lúc:
Bạn muốn quy mô xem này như thế nào? Nên luôn luôn có cùng chiều rộng/chiều cao như thiết bị hoặc bạn có muốn nó ở cùng kích thước vật lý trên mọi thiết bị hay không. Lý do tôi hỏi là bố trí hiện tại của bạn không phải là rất năng động và có thể sẽ kết thúc tìm kiếm kỳ lạ trên nhiều thiết bị. – NasaGeek
ý tưởng nó sẽ mở rộng quy mô thiết bị và trông lớn hơn trong các thiết bị lớn hơn. Tôi biết rằng xml tôi đăng không quy mô nhưng đó chỉ là bước đầu tiên. – Anonymous
Một vài câu hỏi: 1) Phiên bản Android nào là Xperia? Cấp API? 2) Có thể drawable '@ drawable/ta' trong phong cách. Đó có phải là thứ bạn có thể chia sẻ không? Màn hình trông giống như trên trình mô phỏng với màn hình px LDPI 240x320. – Cheticamp