레이아웃 문제를 해결하려고합니다.이 res/layout/my.xml을 Moto G에서 테스트했는데 괜찮 았지만 Nexus S에서 테스트했을 때 버튼이 너무 컸다. 나는 res/layout-xhdpi/my.xml (Moto G는 xhdpi이고 Nexus는 단지 hdpi이기 때문에)을 시도했지만 레이아웃 중 하나는 항상 두 가지 모두에서 팽창합니다 (각 xhdpi에 대해 전혀 다른 점은 없습니다). 가에 가면 즉시) 볼 수있는 다음 값에Nexus S와 Moto G - 레이아웃을 구분할 수 없음
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical"
tools:context=".MainActivity" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:cropToPadding="true"
android:src="@drawable/pil2" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button1"
android:layout_below="@+id/button1"
android:height="90dp"
android:minWidth="150dp" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button2"
android:layout_below="@+id/button2"
android:height="80dp"
android:minWidth="150dp" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button1"
android:layout_alignParentTop="true"
android:height="130dp"
android:minWidth="150dp" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button4"
android:layout_centerHorizontal="true"
android:height="90dp"
android:minWidth="150dp" />
</RelativeLayout>
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="xxxx"
ads:adSize="BANNER" />
</LinearLayout>
드로어 블 리소스 이외의 다른 리소스 리소스에 밀도 리소스 세트 한정자 (예 :'-hdpi')를 사용하면 심각한 코드의 냄새가납니다. 원하는 코드를 얻지 못할 것이라는 것을 거의 확신 할 수 있습니다. 그 외에도 계층 구조보기를 사용하여 레이아웃 규칙에서 어려움을 초래하는 요소를 판별하십시오. – CommonsWare
다음은 Nexus S에서 보이는 모습입니다. http://oi58.tinypic.com/oko8l1.jpg Nexus 5의 모습입니다. http://oi59.tinypic.com/1zlgjud.jpg 물론 버튼은 다음과 같습니다. 제대로 작동하면 투명하게됩니다. 상단의 첫 번째 버튼에는 아무런 기능이 없습니다. marginingTop 대신 자리 표시 자만 있습니다. 나는 항상 내 UI를 재고하고 있지만, 제대로 작동 할 것입니다 어떤 장치에 이렇게 단단한 얻을 수 없습니다. –
PNG/JPEG/배경에 클릭 할 수있는 "버튼"을 표시하려고하는 것 같습니다. 단추가 전체적인 배경과 아무 관련이 없기 때문에 접근 방식은 신뢰할 수 없습니다. – CommonsWare