0

ScrollView属性を持つcustom を作成しようとしましmax_heightたが、問題に直面しました。カスタムを設定するとheight、表示されScrollViewませんTextView

私のコードのライトバージョン:

レイアウト:

<RelativeLayout 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">

<com.example.scrollviewtest.ExpandScrollView
    android:id="@+id/scrollView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:background="#Fe6" >

    <TextView
        android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="TextView TextView TextView TextView TextView" />
</com.example.scrollviewtest.ExpandScrollView>

ExpandScrollView.java

public class ExpandScrollView extends ScrollView {

public ExpandScrollView(Context context) {
    super(context);
}

public ExpandScrollView(Context context, AttributeSet attrs) {
    super(context, attrs);
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int widthSize = MeasureSpec.getSize(widthMeasureSpec);
    setMeasuredDimension(widthSize, 180);

}}

それで、私は何を間違っていますか?

4

2 に答える 2