2016-11-28 4 views
1

OnePlus 3 및 Samsung Galaxy Tab A에서 테스트중인 앱을 개발 중입니다. 태블릿이 최근 내 목록에 추가되었으며 모든 개발 지금까지 원 플러스에 있던 3다른 기기 (AOSP 및 삼성 Galaxy)에서 Android 버튼 스타일이 다르게 보입니다.

내 문제가 갤럭시 태블릿에 다르게 같은 버튼 rendors은 원 플러스 이전 3.

보다는 내가 안드로이드 스튜디오에서 넥서스 9 에뮬레이터에서 응용 프로그램을 시도했다고하고 그것은해야대로 렌더링되었습니다. 이것은 내가 삼성이 내 버튼의 모습을 바꾸고있는 무언가를 망쳐 놓았다고 생각하게 만든다.

더 정확하게 문제를 나타내려면 버튼 배경이 스크린 샷에 표시되는대로 태블릿의 전체보기를 채 웁니다. 나는 그것을 보통의 안드로이드 버튼처럼 만들고 싶다.

내 버튼의 코드는 I 버튼의 배경 (btn_default)을 지정하면 내가 그들 모두에 동일한 모양을 얻을 수있는이

<Button 
    android:id="@+id/outputButton" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="-4dp" 
    android:text="" 
    android:textSize="13sp"/> 

같다. 하지만 분명히 버튼의 애니메이션이 더 이상 작동하지 않게됩니다. 내 이해에 따르면, 기본 스타일 (Widget.AppCompat.Button, 또한 명시 적으로 진술)도 기본 배경 (btn_default)을 사용해야하지만 거기에 내 이해와 함께 몇 가지 결함이있는 것 같다.

그럼 두 장치에서 어떻게 똑같이 보입니까?

갤럭시 탭 A -

enter image description here enter image description here

원 플러스 3 - 대부분 enter image description here

답변

0

음, 알아 냈습니다. 가장 깨끗한 솔루션은 아니지만 작동합니다.

버튼의 배경 드로어 블용으로 사용합니다. 언급 한 값은 재료 설계 소스 파일에서 직접 가져온 것입니다. 단추 모양을 변경하려면 단추를 눌러야합니다. 가장 중요한 것은 리플 태그를 추가하여 표준 애니메이션을 허용해야한다는 것입니다.

<?xml version="1.0" encoding="utf-8"?> 

<inset xmlns:android="http://schemas.android.com/apk/res/android" 
     android:insetBottom="6dp" 
     android:insetLeft="4dp" 
     android:insetRight="4dp" 
     android:insetTop="6dp"> 
    <ripple 
     android:color="?attr/colorControlHighlight"> 
     <item> 
      <shape android:shape="rectangle"> 
       <corners android:radius="2dp"/> 
       <solid android:color="?attr/colorButtonNormal"/> 
       <padding 
        android:bottom="4dp" 
        android:left="8dp" 
        android:right="8dp" 
        android:top="4dp"/> 
      </shape> 
     </item> 
    </ripple> 
</inset> 

왜 처음에는 문제가 발생했는지 이해할 수 없지만 해결했습니다.

0
<android.support.v7.widget.AppCompatButton 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="-4dp" 
     android:text="" 
     android:textSize="13sp" /> 

가 작동

enter image description here 때문에이 AppCompatButton 서브 클래스및 모든 장치와 compactible됩니다.

+0

작동하지 않았습니다. 두 장치에서 똑같은 일을합니다. –