2016-05-11 6 views
1

私は以下の3つのデバイス(以下のイメージ)についてコード化し、Density/Resolution/OSを記録しています(デバイスの種類を知るため)。私は5つのボタンと5つの画像を持っています。各画像の高さは10dpから50dpです。10dp高さボタンはどこにありますか?

すべてのデバイスに画像が表示されます。すべてのボタンはXXXHDPIデバイス(Samsung S7デバイス)に表示されますが、XXHDPI(Nexus 5)とXHDPI(Samsung S3)では10dpボタンが消えました。どうして?

画像Layout run on 3 devices

以下と以下のように私のレイアウト(なし他の特別なコード、単にデフォルト空のアクティビティプロジェクト)など。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 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" 
    android:orientation="vertical" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="com.elyeproj.phoneinfo.MainActivity"> 

    <TextView 
     android:id="@+id/resolution_width" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

    <TextView 
     android:id="@+id/resolution_height" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

    <TextView 
     android:id="@+id/resolution_width_dp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 
    <TextView 
     android:id="@+id/resolution_height_dp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 
    <TextView 
     android:id="@+id/resolution_density" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 
    <TextView 
     android:id="@+id/resolution_density_str" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

    <TextView 
     android:id="@+id/phone_os" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

    <Button 
     android:layout_width="match_parent" 
     android:layout_height="10dp" /> 

    <Button 
     android:layout_width="match_parent" 
     android:layout_height="20dp" /> 

    <Button 
     android:layout_width="match_parent" 
     android:layout_height="30dp" /> 

    <Button 
     android:layout_width="match_parent" 
     android:layout_height="40dp" /> 

    <Button 
     android:layout_width="match_parent" 
     android:layout_height="50dp" /> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="10dp" 
     android:layout_marginBottom="5dp" 
     android:background="@android:color/holo_blue_dark"/> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="20dp" 
     android:layout_marginBottom="5dp" 
     android:background="@android:color/holo_blue_dark"/> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="30dp" 
     android:layout_marginBottom="5dp" 
     android:background="@android:color/holo_blue_dark"/> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="40dp" 
     android:layout_marginBottom="5dp" 
     android:background="@android:color/holo_blue_dark"/> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:background="@android:color/holo_blue_dark"/> 
</LinearLayout> 
+0

ためのボタンの背景

にいくつかの色を設定しますか?そのパディングが削除されているかどうかを確認してみてください。ただし、このような影響はないと思います。 – zgc7009

+0

その理由は、navボタンがあなたの不動産の一部を奪っているようです。できるだけXMLが描画を試みます。しかし、それが部屋を使い果たすと、物事は省略されるかもしれません。 – durbnpoisn

+0

HI @ zgc7009。単純にコード '

答えて

0

より良いテキストビュー、ボタンや画像のための独立したのLinearLayoutを与えることを試みます。そのLinearLayoutのためのアンドロイドレイアウトの重みを使用して...

+0

申し訳ありませんが、あなたは私の質問を得ていないと思います。それはImageViewについてではありません...それはちょうど10dp画像ビューがまだ示すことを示すことです。しかし、10dpのボタンビューでは、完全に消えてしまいます。ボタンから、明らかにXHDPIとXXHDPIのすべてのボタンがそれより小さくなります(私は10dp前後で推測します)。 – Elye

+0

もうひとつ..サムスンs7は4.0の密度です..他のすべてのものはそれより低いです..あなたは10db以下のものを試すことができますか? – Suresh

+0

これは私がs7を指しているのはXXXHDPIですが、解決。 – Elye

0

"問題"は、デフォルトのボタンの背景とその内部のパディングにあります。修正するに - あなたは動的ビューのいずれかをいじっていないあなたは確か例

android:background="@android:color/holo_red_dark" 
+0

背景を設定すると、ボタンの標高効果が失われます。 http://stackoverflow.com/a/27155606/3286489を参照してください。また、問題は、なぜS7にはボタンがあるのですが、他にはありませんか? – Elye

関連する問題