0

문제가 있습니다. 나는 다음과 같은 레이아웃 같은 단편에서 높이를 점점 시도하고조각에서 높이를 얻고 뷰 페이지의 높이를 설정하는 방법은 무엇입니까?

:

에서 @ 문자열/loren_ipsum에서 큰 텍스트를 가져
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:id="@+id/container_frag_informacoes_detalhes" 
tools:context="br.com.magazineluiza.mobilevendas.userinterface.detalhesproduto.FragInformacoesDetalhesProduto"> 

<TextView 
    android:id="@+id/tv_frag_information_detalhes" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/loren_ipsum"/> 

.

나는 그 높이를 얻으려고 노력하고 있지만 나는 할 수 없다.

어떻게하면됩니까?

답변

1

방법에 대한 다음 onCreateView에서

TextView tv = (TextView) getActivity().findViewbyId(R.id.tv_frag_information_detalhes); 
final int height = tv.getHeight(); 

.

+0

이미 시도했지만, 0을 반환했습니다. 나는 여전히 linearLayout, 조각보기 및 모두의 measureHeight 높이를 가져 오려고했습니다. 또한 ViewTreeObserver.OnGlobalLayoutListener()에서 가져 오려고했으나 0도 반환했습니다. 방금 ​​사용자 정의 viewPager를 만들고 onMeasure를 편집하려했지만 잘못된 값으로 크기가 조정되었습니다 –

+0

View.post()를 사용해보십시오. –

관련 문제