1

세로 가이드 라인을 추가 한 후 위의 화살표를 클릭하면 백분율로 바뀌지 만 내 android 스튜디오 또는 사용중인 제한 레이아웃 버전에 이상이 있습니다. 또는 나는 여기에서 대단히 잘못된 것을하고 있을지도 모른다.세로 가이드 라인을 백분율로 변환하는 방법

enter image description here

것은 내가 모든 것을 시도했다, 그러나 그것은 항상 같은 arrorw을 보여주고, 내가 그것을 클릭하면, 비율 자체를 전환하지 않습니다.

나는 Android Studio 2.2을 사용하고 있으며 이것을 내 그라디언트에 추가했습니다.

compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'

친절하게 방법을 백분율로이를 변환하는 저를 안내합니다.

+0

또는 android.support.percent.PercentRelativeLayout 또는 PercentFrameLayout보기를 사용하십시오 (지원 라이브러리 - com.android.support:percent에서 찾을 수 있음). 그런 다음 app : layout_widthPercent = "num %"또는 유사한 제약 조건을 자식에 사용할 수 있습니다. – MVojtkovszky

답변

3

그것은

안드로이드 스튜디오 2.3에서 작동
compile 'com.android.support.constraint:constraint-layout:1.0.1' 

그러나 몇 가지 문제가 있습니다. s 사용법. 때로는 아이콘이 다른 항목 아래에 숨겨져있어 클릭하기가 어려울 때가 있으며 아이콘을 클릭하면 다른 항목이 선택됩니다. 나는 때때로 큰 거래를 확대 한 다음 작은 삼각형의 아이콘 중간을 오른쪽 클릭 할 필요가 있음을 발견했다. 클릭 한 번으로 지침의 방향이 바뀌고 두 번 클릭하면 비율로 변환됩니다.

그래도 실패하면 xml을 직접 변경할 수 있습니다. 예를 들어

app:layout_constraintGuide_percent="0.3611111" 

app:layout_constraintGuide_begin="51dp" 

교체합니다.

1

당신은 비율 패키지 추가 및 앱에 비율을 기반으로 치수 관리를 지원하기 위해 API를 제공 Percent Support Library

사용할 수 있습니다.

프로젝트에 따라 당신의 Gradle을 구축 스크립트 변경 버전에 대한 종속성을 추가

compile 'com.android.support:percent:24.2.1' 

레이아웃, 당신은 PercentRelativeLayout를 추가 할 수 있습니다.

당신은 "퍼센트"접미사 예를 들어

와 속성 를 사용하여 차원 또는 아이의 여백을 지정할 수 있습니다

<android.support.percent.PercentRelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
    <ImageView 
     app:layout_widthPercent="50%" 
     app:layout_heightPercent="50%" 
     app:layout_marginTopPercent="25%" 
     app:layout_marginLeftPercent="25%"/> 
</android.support.percent.PercentRelativeLayout> 
+0

@ Kirmani88 유용 할 경우 동의 해주시기 바랍니다. – LaurentY