min height fill_parent and height wrap_content in ScrollView? (or just the email app compose layout's code)

后端 未结 4 355
时光说笑
时光说笑 2021-02-01 03:57

Question If I have the following:


    

        
相关标签:
4条回答
  • 2021-02-01 04:41

    I ran across a link to the mail app source code in my accepted answer on another question. The answer is simple! Add android:fillViewport="true" to the <ScrollView...> and add android:layout_weight="1.0" to the view you want to take up all the available space. explained in this blogspot

    0 讨论(0)
  • 2021-02-01 04:43

    Why don't you make the ScrollView being fill_parent and A and B to wrap_content ? The only thing you want is that your ScrollView fits the screen.

    0 讨论(0)
  • 2021-02-01 04:45

    after you call

    AlertDialog dialog = builder.show();
    

    then call

    fixScrollViewHeight(scrollView);
    
    private void fixScrollViewHeight(ScrollView scrollView)
    {
        int screenHeight = activity.getWindowManager().getDefaultDisplay().getHeight();
        LayoutParams lp = scrollView.getLayoutParams();
        lp.height = screenHeight / 3;
        scrollView.setLayoutParams(lp);
    }
    
    0 讨论(0)
  • 2021-02-01 04:53

    As mentioned above the right way is to use the android:fillViewport="true" attribute.

    There is an example, where the image will be positioned at the and of scrollView:

      <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fillViewport="true">
        <LinearLayout
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:fillViewport="true"
          android:orientation="vertical">
    
          <LinearLayout
            android:layout_height="fill_parent"
            android:layout_width="wrap_content"
            android:orientation="vertical"
            android:layout_weight="1">
            <TextView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="test"/>
          </LinearLayout>
    
    
          <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:background="@color/red">
            <ImageView
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:adjustViewBounds="true"
              android:src="@drawable/about_us_image_1_land"
              style="@style/layout_marginTop20"/>
          </LinearLayout>
        </LinearLayout>
       </ScrollView>
    
    0 讨论(0)
提交回复
热议问题