I have a ScrollView
like :
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/place_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@mipmap/tourist_place_details" />
<ImageView
android:id="@+id/images"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="20dp"
android:src="@mipmap/ic_imagegallery" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:minWidth="30dp"
android:layout_gravity="center_vertical"
android:src="@mipmap/icon_clock" />
<TextView
android:id="@+id/txt_time"
style="@android:style/TextAppearance.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginLeft="10dp"
android:text="9:00am - 6:00pm"
android:textColor="@color/gray_categories" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@color/divider" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:minWidth="30dp"
android:layout_gravity="center_vertical"
android:src="@mipmap/icon_fare" />
<TextView
android:id="@+id/txt_fare"
style="@android:style/TextAppearance.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginLeft="10dp"
android:ellipsize="end"
android:maxLines="1"
android:text="Adult 10/- Child 5/- Tourist 100/-"
android:textColor="@color/gray_categories" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@color/divider" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:minWidth="30dp"
android:layout_gravity="center_vertical"
android:src="@mipmap/ic_location" />
<TextView
android:id="@+id/txt_address"
style="@android:style/TextAppearance.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginLeft="10dp"
android:ellipsize="end"
android:maxLines="2"
android:text="blah balh blah"
android:textColor="@color/gray_categories" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@color/divider" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:minWidth="30dp"
android:layout_gravity="center_vertical"
android:src="@mipmap/icon_call" />
<TextView
android:id="@+id/txt_contact_numbers"
style="@android:style/TextAppearance.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginLeft="10dp"
android:ellipsize="end"
android:maxLines="1"
android:text="+1 999999999999"
android:textColor="@color/gray_categories" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@color/divider" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_margin="10dp"
android:background="@mipmap/image_map"
android:orientation="vertical">
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@color/divider" />
<TextView
android:id="@+id/txt_about"
style="@android:style/TextAppearance.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:paddingLeft="5dp"
android:text="@string/about"
android:textColor="@color/gray_categories" />
<TextView
android:id="@+id/txt_desc"
style="@android:style/TextAppearance.Small"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:paddingLeft="5dp"
android:layout_marginRight="10dp"
android:ellipsize="end"
android:visibility="gone"
android:maxLines="5"
android:text="asdkjsadkja adslkgsadkjbsakd asdkjsadkja aldsgsakjdbdlkashdkjsabhdk lashdlksajd asdhkj asdkj askjd asjhd lakjhsbd asdkjsadkja adslkgsadkjbsakd aldsgsakjdbdlkashdkjsabhdk lashdlksajd asdhkj asdkj askjd asjhd lakjhsbd "
android:textColor="@color/gray_categories" />
</LinearLayout>
</ScrollView>
The "About" TextView
is visible and the txt_desc
is hidden.
on clicking the About, 'm making the txt_desc
visible with animation slide down using following method :
public static void expand(final View v) {
v.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
final int targetHeight = v.getMeasuredHeight();
// Older versions of android (pre API 21) cancel animations for views
// with a height of 0.
v.getLayoutParams().height = 1;
v.setVisibility(View.VISIBLE);
Animation a = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime,
Transformation t) {
v.getLayoutParams().height = interpolatedTime == 1 ? LayoutParams.WRAP_CONTENT
: (int) (targetHeight * interpolatedTime);
v.requestLayout();
}
@Override
public boolean willChangeBounds() {
return true;
}
};
// 1dp/ms
a.setDuration((int) (targetHeight / v.getContext().getResources()
.getDisplayMetrics().density));
v.startAnimation(a);
}
The TextView
txt_desc
is expanding but not visible as the ScrollView
stays at About and below txt_desc
content is not being shown. If we scroll, the content is visible.
Can anyone help on making the txt_desc
visible after making it visible.
I have already used scrollView.fullScroll(View.FOCUS_DOWN);
, but no use