forked from organicmaps/organicmaps
Merge pull request #5351 from goblinr/MAPSME-138-ext-fix-hotels-filter-dialog-landscape-master
[android] [cherry-pick] adaptive height for hotels filter dialog
This commit is contained in:
commit
7f6fb8e3c3
2 changed files with 43 additions and 6 deletions
|
@ -12,9 +12,8 @@
|
|||
android:background="@color/bg_dialog_translucent"
|
||||
android:alpha="0"
|
||||
tools:alpha="1"/>
|
||||
<LinearLayout
|
||||
<RelativeLayout
|
||||
android:id="@+id/frame"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?cardBackground"
|
||||
|
@ -55,14 +54,19 @@
|
|||
tools:targetApi="jelly_bean"/>
|
||||
</RelativeLayout>
|
||||
<FrameLayout
|
||||
android:id="@+id/elevation"
|
||||
style="@style/MwmWidget.FrameLayout.Elevation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/header"/>
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scroll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/elevation">
|
||||
<LinearLayout
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/hotels_filter_padding"
|
||||
|
@ -111,7 +115,9 @@
|
|||
<RelativeLayout
|
||||
android:id="@+id/buttons_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/height_block_base">
|
||||
android:layout_height="@dimen/height_block_base"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="?cardBackground">
|
||||
<include layout="@layout/divider_horizontal"/>
|
||||
<View
|
||||
android:id="@+id/center_divider"
|
||||
|
@ -144,5 +150,5 @@
|
|||
android:background="?clickableBackground"
|
||||
tools:targetApi="jelly_bean"/>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</merge>
|
||||
|
|
|
@ -2,15 +2,19 @@ package com.mapswithme.maps.search;
|
|||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.util.Animations;
|
||||
|
@ -32,6 +36,10 @@ public class HotelsFilterView extends FrameLayout
|
|||
private View mFade;
|
||||
private RatingFilterView mRating;
|
||||
private PriceFilterView mPrice;
|
||||
private View mContent;
|
||||
private View mElevation;
|
||||
private int mHeaderHeight;
|
||||
private int mButtonsHeight;
|
||||
|
||||
@Nullable
|
||||
private HotelsFilterListener mListener;
|
||||
|
@ -65,6 +73,10 @@ public class HotelsFilterView extends FrameLayout
|
|||
|
||||
private void init(Context context)
|
||||
{
|
||||
Resources res = context.getResources();
|
||||
mHeaderHeight = (int) res.getDimension(
|
||||
UiUtils.getStyledResourceId(context, android.R.attr.actionBarSize));
|
||||
mButtonsHeight = (int) res.getDimension(R.dimen.height_block_base);
|
||||
LayoutInflater.from(context).inflate(R.layout.hotels_filter, this, true);
|
||||
}
|
||||
|
||||
|
@ -76,6 +88,8 @@ public class HotelsFilterView extends FrameLayout
|
|||
mFade = findViewById(R.id.fade);
|
||||
mRating = (RatingFilterView) findViewById(R.id.rating);
|
||||
mPrice = (PriceFilterView) findViewById(R.id.price);
|
||||
mContent = mFrame.findViewById(R.id.content);
|
||||
mElevation = mFrame.findViewById(R.id.elevation);
|
||||
findViewById(R.id.cancel).setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
|
@ -109,6 +123,23 @@ public class HotelsFilterView extends FrameLayout
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
|
||||
{
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
mContent.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
|
||||
mElevation.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
|
||||
int height = mContent.getMeasuredHeight() + mHeaderHeight + mButtonsHeight
|
||||
+ mElevation.getMeasuredHeight();
|
||||
if (height >= getMeasuredHeight())
|
||||
height = LayoutParams.WRAP_CONTENT;
|
||||
|
||||
ViewGroup.LayoutParams lp = mFrame.getLayoutParams();
|
||||
lp.height = height;
|
||||
mFrame.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
private void cancel()
|
||||
{
|
||||
updateViews();
|
||||
|
|
Loading…
Add table
Reference in a new issue