픽셀 단위로 문자열 길이 얻기 :나는 다음과 같이 보이는 레이아웃이
|User Name | |
|[email protected] | info |
을 그리고 나는 그것이 텍스트 뷰에 맞는 경우에만 이름 경우 사용자의 이름과 두 번째 이름을 설정해야합니다 이름과 두 번째 이름 현재 화면에 비해 너무 깁니다.
|Tom Smith | |
|[email protected] | info |
및 대한
"톰 VeryVeryVeryLongSurname": 내가 지정한 텍스트 크기와 이름의 크기를 얻을 수 및 텍스트 뷰의 폭과 비교 어떻게|Tom | |
|[email protected] | info |
"톰 스미스"에 대한 예를 들어
?<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<TextView
android:id="@+id/info"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="bottom"/>
</LinearLayout>
http://stackoverflow.com/questions/3630086/how-to-get-string-width-on-android – Carnal