내 프로그램 상단에 두 개의 버튼이있어서 각기 다른 활동을하고 싶습니다. 형식 지정에 많은 문제가 있습니다.Android ImageButton 해결 문제
버튼이 화면 크기에 비례하여 늘어날 수 있도록하려면 어떻게해야합니까? 바로 지금, 그들은 한 화면 크기에 대해 괜찮아 보일 것입니다, 그러면 다른 화면으로 바꿀 것입니다. 다른 ScaleTypes를 모두 시도했지만 아무 것도 차이를 만들 수없는 것 같습니다. 나는 또한 갔고 비례 적으로 모든 이미지를 올바른 크기의 xhdpi, hdpi 등의 적절한 크기로 저장했다. Shubhayu's answer을 사용했다.
여기에 지금까지 내 코드입니다 : 당신은 화면의 상단에있는 버튼 균등하게 크기를하려고하는 추측하고<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:background="@drawable/brushed_metal_background_dark"
tools:context=".HomeActivity" >
<ImageButton
android:id="@+id/incidentsSelect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/incident_bar2"
android:contentDescription="Incidents"
android:onClick="chooseIncident"
android:scaleType="center" />
<ImageButton
android:id="@+id/operationalPeriodsSelect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/operationalperiod_bar2"
android:contentDescription="Operational Periods"
android:onClick="chooseOperationalPeriod"
android:scaleType="fitCenter" />
감사! 또한 안드로이드 : background = "@ null"을 사용하여 칙칙한 배경 테두리를 제거해야했습니다. –