0

중복으로 표시하기 전에 충분히 읽으십시오. 이것은 안드로이드에 텍스트와 함께 다른 진행률 막대를 만드는 것에 관한 것이 아닙니다. 진행률 표시 줄 크기를 동적으로 설정하여 텍스트 크기를 커버하고 싶습니다. 다른 솔루션은 거대한 진도 표시 줄의 중간에 작은 텍스트를 넣습니다. 이것은 약간 그것을 커버해야합니다.타원형 ProgressBar 조심스럽게 텍스트 캡쳐

텍스트 뷰가있는 타원형 진행 표시 줄을 가운데에 만들려고합니다. 전체 진행 표시 줄에 텍스트를 캡슐화하고 싶습니다. 그래서 너비와 높이가 일정하지 않아야합니다. 대신 텍스트 뷰보다 약간 커야합니다. 나는 progressbar와 textview (width/height : wrap_content)를 상대적 레이아웃으로 캡슐화하려고했다. 나는 textview와 textbar와 함께 progressbar의 왼쪽/오른쪽/아래/위쪽을 약간의 음수 패딩으로 정렬하려고 시도했지만 난 타원형 진행 표시 줄을 자른다. 다음은 레이아웃 파일입니다.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" android:layout_height="wrap_content"> 
<ProgressBar 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/progressbar0" 
    android:layout_alignLeft="@id/txtCategoryTitle" 
    android:layout_alignRight="@id/txtCategoryTitle" 
    android:paddingLeft="-50dp" 
    android:paddingRight="-50dp" 

    android:layout_alignTop="@id/txtCategoryTitle" 
    android:layout_alignBottom="@id/txtCategoryTitle" 
    android:paddingTop="-50dp" 
    android:paddingBottom="-50dp" 

    android:indeterminate="false" 
    android:progressDrawable="@drawable/circle" 
    style="?android:attr/progressBarStyleHorizontal" 
    android:max="100" 
    android:progress="65" 
    android:layout_below="@id/clickBtn" 
    android:layout_centerInParent="true" 
    > 

</ProgressBar> 

<TextView 
    android:id="@+id/txtCategoryTitle" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textColor="#FFFFFF" 
    android:text="MY CUSTOM TEXT" 
    android:layout_centerInParent="true" 
    android:layout_centerVertical="true" 
    android:elevation="5dp"/> 
</RelativeLayout> 

또한이 작업을보다 쉽고 간편하게 수행 할 수있는 방법에 대한 제안이 있습니다.

답변

0

신경 쓰지 마세요, 어리석은 접근이었습니다. 나중에 참조 할 수있는 새로운 코드는 다음과 같습니다

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" android:layout_height="wrap_content"> 
    <TextView 
     android:id="@+id/txtCategoryTitle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:paddingTop="10dp" 
     android:paddingBottom="10dp" 
     android:paddingLeft="10dp" 
     android:paddingRight="10dp" 

     android:textColor="#FFFFFF" 
     android:text="MY CUSTOM TEXT" 
     android:layout_centerInParent="true" 
     android:elevation="5dp"/> 

    <ProgressBar 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@id/txtCategoryTitle" 
     android:layout_alignRight="@id/txtCategoryTitle" 
     android:layout_alignTop="@id/txtCategoryTitle" 
     android:layout_alignBottom="@id/txtCategoryTitle" 
     android:id="@+id/progressbar0" 
     android:indeterminate="false" 
     android:progressDrawable="@drawable/circle" 
     style="?android:attr/progressBarStyleHorizontal" 
     android:max="100" 
     android:progress="65" 
     > 

    </ProgressBar> 





</RelativeLayout>