2016-08-18 2 views
0
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/layout_one" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.example.william.calculator2.MainActivity"> 

    <LinearLayout 
    android:orientation="vertical"  
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/grey"> 

    <TextView 
     android:layout_weight="2" 
     android:id="@+id/text" 
     android:layout_width="match_parent" 
     android:textSize="50sp" 
     android:gravity="center" 
     android:textColor="@color/colorPrimary" 
     android:layout_height="0dp" 
     android:background="@color/white" 
     android:text="@string/one" /> 


<Button 
     android:layout_marginTop="20dp" 
     android:id="@+id/button_1" 
     android:background="@drawable/plus" 
     android:layout_width="80dp" 
     android:layout_height="0dp" 
     android:layout_marginLeft="10dp" 
     android:layout_weight="1" 
     android:onClick="setSubtractionOperator"/> 

<Button 

     android:id="@+id/button_2" 

     android:background="@drawable/minus" 
     android:layout_marginTop="20dp" 
     android:layout_weight="1" 
     android:layout_marginLeft="10dp" 
     android:layout_width="80dp" 
     android:layout_height="0dp" /> 


    <Button 
     android:layout_weight="1" 
     android:id="@+id/button_3" 
     android:background="@drawable/one" 
     android:layout_marginTop="20dp" 
     android:layout_marginLeft="10dp" 
     android:layout_width="80dp" 
     android:layout_height="0dp" 
     android:onClick="useNumber1"/> 
    <Button 
     android:layout_weight="1" 
     android:id="@+id/button_4" 
     android:layout_marginLeft="10dp" 
     android:background="@drawable/roundedbutton" 
     android:layout_marginTop="20dp" 
     android:layout_marginBottom="20dp" 
     android:layout_width="wrap_content" 
     android:layout_height="0dp" /> 

    </LinearLayout> 
</RelativeLayout> 

네, 제 단추의 크기가 하드 코드되었음을 알고 있습니다. 그러지 않으려 고 노력했지만 어떤 방법으로도 작동하지 않습니다. 나는 초보자이기 때문에 제 실수에 대해 제발 벌점을주지 마십시오. 모든 도움에 감사드립니다. 에있어서 button_1의 onclick을, 당신은 "SetSubstractionOperator"같은 이름의 레이아웃과의 방법을 이름을 지정해야합니다, 당신의 MainActivity에서Android Studio : 휴대 전화에서 크기가 조절되지 않는 버튼이 있습니까?

This is in Studio When run

+0

이것은 Studio에서 하나의 스크린 샷입니다. 실행하면 또 다른 것입니다. – Willie3838

답변

0

:

여기 스크린 샷입니다.

+0

죄송합니다. 버튼을 사용하면 어떻게 도움이 될까요? (자바가 작동하지 않는다는 것을 알고 있는데, 현재 디스플레이에 집중하고 있습니다.) – Willie3838

0

모든 화면의 해상도가 다르기 때문에 하드 코딩 된 너비와 높이를 사용하면 모든 화면의 배율을 조정하는 데 도움이되지 않습니다. 화면에 따라 드로어 블을 만드십시오.

+0

그러나 모든 화면에서 동일하게되기를 원하십니까? 내 화면 만이 아니야. – Willie3838

관련 문제