Fix layout

This commit is contained in:
Victor Shcherb 2016-08-22 15:43:00 +03:00
parent abc21fe6ff
commit c3489e1fc3
2 changed files with 16 additions and 0 deletions

View file

@ -38,6 +38,8 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="@dimen/map_widget_height"
android:id="@+id/widget_bottom_layout"
android:orientation="horizontal" >
<ImageView

View file

@ -8,9 +8,13 @@ import android.graphics.Paint.Style;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
public class TextInfoWidget {
@ -30,11 +34,13 @@ public class TextInfoWidget {
private int dayIcon;
private int nightIcon;
private boolean isNight;
private ViewGroup bottomLayout;
public TextInfoWidget(Activity activity) {
app = (OsmandApplication) activity.getApplication();
view = activity.getLayoutInflater().inflate(R.layout.map_hud_widget, null);
bottomLayout = (ViewGroup) view.findViewById(R.id.widget_bottom_layout);
topImageView = (ImageView) view.findViewById(R.id.widget_top_icon);
topTextView = (TextView) view.findViewById(R.id.widget_top_icon_text);
imageView = (ImageView) view.findViewById(R.id.widget_icon);
@ -75,12 +81,20 @@ public class TextInfoWidget {
if(imageDrawable != null) {
topImageView.setImageDrawable(imageDrawable);
topImageView.setVisibility(View.VISIBLE);
LinearLayout.LayoutParams lp = (android.widget.LinearLayout.LayoutParams) bottomLayout.getLayoutParams();
lp.gravity = Gravity.CENTER_HORIZONTAL;
bottomLayout.setLayoutParams(lp);
bottomLayout.invalidate();
topTextView.setVisibility(View.VISIBLE);
topTextView.setText(topText == null ? "" : topText);
} else {
topImageView.setVisibility(View.GONE );
topTextView.setVisibility(View.GONE );
LinearLayout.LayoutParams lp = (android.widget.LinearLayout.LayoutParams) bottomLayout.getLayoutParams();
lp.gravity = Gravity.NO_GRAVITY;
bottomLayout.setLayoutParams(lp);
}
topTextView.invalidate();
topImageView.invalidate();
}