Android 진행률 표시 줄의 높이를 설정하는 방법은 무엇입니까?
내는 activity_main.xml당신이 보는대로, 높이가 40 수영을 설정, 다음과 같습니다.
그리고 MyEclipse에서는 다음과 같습니다.

하지만 내 전화에서 실행하면 다음과 같이 보입니다.

그래서 내 질문은 진행률 표시 줄의 실제 높이가 내가 설정 한 높이가 아닌 이유입니다. 진행률 표시 줄의 높이를 높이는 방법은 무엇입니까?
에서 이 튜토리얼 :
<style name="CustomProgressBarHorizontal" parent="android:Widget.ProgressBar.Horizontal">
<item name="android:progressDrawable">@drawable/custom_progress_bar_horizontal</item>
<item name="android:minHeight">10dip</item>
<item name="android:maxHeight">20dip</item>
</style>
그런 다음 진행률 표시 줄 이상에 스타일을 적용하고 테마의 기본 스타일을 재정 의하여 앱의 모든 진행률 표시 줄에 자동으로 스타일을 지정합니다.
스크린 샷에서 볼 수있는 차이점은 휴대폰 / 에뮬레이터가 다른 Android 버전을 사용하고 있기 때문입니다 (최신은 ICS (Holo)의 테마, 상단은 원래 테마).
가장 간단한 해결책은 다음과 같습니다.
mProgressBar.setScaleY(3f);
xml 파일의 android : scaleY = "8"
이것을 사용하십시오
style="@android:style/Widget.ProgressBar.Horizontal"
다른 답변에서 언급했듯이 Holo.Light를 사용하도록 진행률 표시 줄의 스타일을 설정하는 것 같습니다.
style="@android:style/Widget.Holo.Light.ProgressBar.Horizontal"
이것이 휴대폰에서 실행되고 있다면 아마도 3.0+ 장치 일 것입니다. 그러나 에뮬레이터는 "기본"진행률 표시 줄을 사용하는 것처럼 보입니다.
style="@android:style/Widget.ProgressBar.Horizontal"
화면 캡처를 만드는 사이에 스타일을 "기본"진행률 표시 줄로 변경 했습니까? 안타깝게도 2.x 장치는 프로젝트에서 Holo.Light 진행률 표시 줄을 사용하는 경우 자동으로 "기본"진행률 표시 줄로 돌아 가지 않습니다. 그냥 충돌합니다.
실제로 기본 진행률 표시 줄을 사용하는 경우 제안 된대로 최대 / 최소 높이를 설정하면 제대로 작동합니다. 그러나 Holo.Light (또는 Holo) 막대를 사용하는 경우 최대 / 최소 높이 설정이 작동하지 않습니다. 다음은 최대 / 최소 높이를 25 및 100 딥으로 설정 한 샘플 출력입니다.
25 dip로 설정된 최대 / 최소 : 
max/min set to 100 dip: 
You can see that the underlying drawable (progress_primary_holo_light.9.png) isn't scaling as you'd expect. The reason for this is that the 9-patch border is only scaling the top and bottom few pixels:

The horizontal area bordered by the single-pixel, black border (green arrows) is the part that gets stretched when Android needs to resize the .png vertically. The area in between the two red arrows won't get stretched vertically.
The best solution to fix this is to change the 9patch .png's to stretch the bar and not the "canvas area" and then create a custom progress bar xml to use these 9patches. Similarly described here: https://stackoverflow.com/a/18832349
다음은 비 결정적 Holo.Light ProgressBar에 대한 구현입니다. Indeterminant 및 Holo ProgressBars에 대한 고유 한 9 패치를 추가해야합니다. 이상적으로는 캔버스 영역을 완전히 제거해야했습니다. 대신 나는 그것을 떠났지만 "바"영역을 늘릴 수 있도록 설정했습니다. https://github.com/tir38/ScalingHoloProgressBar
<ProgressBar
android:minHeight="20dip"
android:maxHeight="20dip"/>
values-> styles.xml
<style name="tallerBarStyle" parent="@android:style/Widget.SeekBar">
<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">@android:drawable/progress_horizontal</item>
<item name="android:indeterminateDrawable">@android:drawable/progress_horizontal</item>
<item name="android:minHeight">8dip</item>
<item name="android:maxHeight">20dip</item>
</style>
그런 다음 ProgressBar에서 다음을 추가하십시오.
style="@style/tallerBarStyle"
이것은 내가 사용한 진행률 표시 줄입니다.
<ProgressBar
android:padding="@dimen/dimen_5"
android:layout_below="@+id/txt_chklist_progress"
android:id="@+id/pb_media_progress"
style="@style/MyProgressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:progress="70"
android:scaleY="5"
android:max="100"
android:progressBackgroundTint="@color/white"
android:progressTint="@color/green_above_avg" />
그리고 이것은 내 스타일 태그
<style name="MyProgressBar" parent="@style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressBackgroundTint">@color/white</item>
<item name="android:progressTint">@color/green_above_avg</item>
</style>
진행률 표시 줄의 스타일을 다음과 같이 설정할 수 있습니다.
style="@android:style/Widget.ProgressBar.Horizontal"
참고 URL : https://stackoverflow.com/questions/13509989/how-to-set-the-android-progressbars-height
'Nice programing' 카테고리의 다른 글
| Typescript로 객체 배열에 대한 인터페이스를 어떻게 정의 할 수 있습니까? (0) | 2020.11.25 |
|---|---|
| 서버가 이미 실행 중입니다. (0) | 2020.11.25 |
| 프로그래밍 방식으로 SearchView를 닫는 방법은 무엇입니까? (0) | 2020.11.25 |
| 코드 생성 UIView에 UIBezierPath 그리기 (0) | 2020.11.25 |
| 입력을 대문자로 변경 (0) | 2020.11.25 |