1
나는 원으로 된 이미지를 가지고 있습니다. 그 안의 일부만 스트레칭을하고 싶습니다. 스트레치 보더를 원하지 않습니다. 는 예를 들어 내 이미지는 텍스트가 중심 검은 원의 원과 텍스트 장소로 스트레칭 큰 경우 backgrount입니다 내 textview.i이 원하는대로 내가 설정9 개의 패치가있는 원형 이미지 안의 스트레치 방법
다음과 같습니다.
나는 원으로 된 이미지를 가지고 있습니다. 그 안의 일부만 스트레칭을하고 싶습니다. 스트레치 보더를 원하지 않습니다. 는 예를 들어 내 이미지는 텍스트가 중심 검은 원의 원과 텍스트 장소로 스트레칭 큰 경우 backgrount입니다 내 textview.i이 원하는대로 내가 설정9 개의 패치가있는 원형 이미지 안의 스트레치 방법
다음과 같습니다.
9 패치 이미지를 사용하지 못할 수 있습니다. 그러나 귀하의 요구 사항은 형상 drawables를 사용하여 얻을 수 있다고 생각합니다. 다음은 참조 할 수있는 샘플 코드입니다.
<solid android:color="#ffffff" />
<stroke
android:width="10dp"
android:color="#000000" />
<size
android:height="120dp"
android:width="120dp" />
2.inner_circle.xml
: 다음코드입니다 6,
<!-- Give the padding so the text does not touches the edge of inner circle -->
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp" />
<solid android:color="#000000" />
3.Layout 샘플
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/outer_circle"
android:gravity="center" >
<TextView
android:id="@+id/textTest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/inner_circle"
android:gravity="center"
android:text="Test"
android:textColor="#aaaaaa"
android:textStyle="bold" />
</LinearLayout>
4.Set 텍스트 뷰 레이아웃 프로그래밍
// Override this method to get the text width dynamically and
// apply the same height to the textview
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
TextView tvTest = (TextView) findViewById(R.id.textTest);
int tvWidth = tvTest.getWidth();
ViewGroup.LayoutParams tvLayout = tvTest.getLayoutParams();
tvLayout.height = tvLayout.width = tvWidth;
tvTest.setLayoutParams(tvLayout);
}
다음 샷의 일부
,536 이How to draw a smaller ShapeDrawable inside another shapeDrawable programmatically
이 도움이 될 것입니다 희망을 링크로
또는 당신은 모양을 가질 수 있습니다.
그래서 내부 도트를 축소/확대하고 외부 원을 동일한 테두리 너비로 축소/확대 시키길 원하십니까? – pskink
9 패치 드로어 블 (patchable drawable)로 할 수 있을지는 의문입니다. 대신 링 그라디언트를 사용해보십시오. – matiash