Reputation: 452
The HorizontalScrollView is in a Fragment why RUNNABLE use that advises people but still does not work.
public class AvailabilityHorizontalScrollView extends HorizontalScrollView {
public AvailabilityHorizontalScrollView(Context context) {
super(context);
inflate(context);
find();
}
public AvailabilityHorizontalScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
inflate(context);
find();
}
private void inflate(Context context){
inflate(context, R.layout.horizontal_scrollview_availability, this);
}
private void find() {
availabilityLL = (LinearLayout) findViewById(R.id.hsa_container_ll);
}
private void scrollToCurrentReservation() {
this.postDelayed(new Runnable() {
@Override
public void run() {
scrollTo(250,250);
invalidate();
}
},250);
}
Here the CODE of the AvailabilityHorizontalScrollView intro the XML for Fragment:
<es.sw.bluemove.customview.AvailabilityHorizontalScrollView
android:id="@+id/fld_availability_sv"
android:layout_marginTop="@dimen/margin_s"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</es.sw.bluemove.customview.AvailabilityHorizontalScrollView>
Here the CODE of "hsa_container_ll":
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/hsa_availability_sv"
android:layout_marginTop="@dimen/margin_med"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbarStyle="outsideInset">
<LinearLayout
android:id="@+id/hsa_container_ll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
</LinearLayout>
</HorizontalScrollView>
Upvotes: 0
Views: 85
Reputation: 452
I find finally my problem:
The view that contains Horizontal Layout has the property in xml VISIBLE = GONE; this make me crazy to find about to move horizontal scrollview to my desired position because it didn't move when the view make visible = true.
ScrollTo didn't work to me because view has property GONE, like i said. I changed the property to INVISIBLE and the instruction scrollTo works perfectly. The absence HorizontalScrollview was the problem.
Upvotes: 1
Reputation: 3497
hsa_caontainer_ll
as root view in .xml
file:
private void inflate(Context context){
View inflated = inflate(context, R.layout.horizontal_scrollview_availability, this);
addView(inflated);
}
After that You can find Your View via findViewById()
Upvotes: 0