0

enter image description here

Red text came out a little small. Here is what it says:

Need to get the background color of the dialog so I can set the background of the "more info" textview to that same color. Need to do this programmatically because color of the dialog is different depending on API level.

Java code:

public class CityDetailDialog extends DialogFragment {

    private SharedPreferences sharedPreferences;
    private City mCity;
    private LinearLayout mCityContainerLayout;
    private ImageView mImageFlag;
    private TextView mTextCity;
    private ImageView mImageCity;
    private ImageButton mButtonGoogleMaps;
    private ImageButton mButtonWikipedia;
    private TextView mMoreInfoTextView;

    public CityDetailDialog() {
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        sharedPreferences = getActivity().getSharedPreferences("settings", Context.MODE_PRIVATE);
        return inflater.inflate(R.layout.dialog_city_detail, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mCity = (City) getArguments().getSerializable("city");
        mCityContainerLayout = (LinearLayout) view.findViewById(R.id.container_city_dialog);
        mImageFlag = (ImageView) view.findViewById(R.id.flag_image);
        mTextCity = (TextView) view.findViewById(R.id.city_name);
        mImageCity = (ImageView) view.findViewById(R.id.city_image);
        mButtonGoogleMaps = (ImageButton) view.findViewById(R.id.button_google_maps);
        mButtonWikipedia = (ImageButton) view.findViewById(R.id.button_wikipedia);
        mMoreInfoTextView = (TextView) view.findViewById(R.id.more_info_label);

        mImageFlag.setImageResource(ResourceByNameRetriever.getDrawableResourceByName(mCity.
                getCountryName(), getActivity()));
        mTextCity.setText(ResourceByNameRetriever.getStringResourceByName(mCity.getCityName(),
                getActivity()));
        Picasso.with(getActivity()).load(mCity.getImageUrl()).into(mImageCity);

        mButtonGoogleMaps.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent mapsIntent = new Intent(Intent.ACTION_VIEW);
                mapsIntent.setData(Uri.parse("geo:" + mCity.getCoordinates()));
                Intent chooser = Intent.createChooser(mapsIntent, getString(R.string.launch_maps));
                startActivity(chooser);
            }
        });

        mButtonWikipedia.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent wikiIntent = new Intent(Intent.ACTION_VIEW);
                wikiIntent.setData(Uri.parse(mCity.getWikiUrl()));
                Intent chooser = Intent.createChooser(wikiIntent, getString(R.string.launch_browser));
                startActivity(chooser);
            }
        });
    }

}

nicoqueijo
  • 872
  • 2
  • 11
  • 28
  • please share the java code that you written to implement the dialog. – Kavach Chandra Aug 06 '17 at 21:53
  • @KavachChandra added – nicoqueijo Aug 06 '17 at 21:59
  • So I tried running an app with various methods such as mMoreInfoTextView.bringToFront() and setting background color to textView but couldn't achieve the effect that you've shown in the picture on the right. TexView always took the background of the elements below it i.e when i crossed a line through it, the line was still visible even when i brought the view to front. The only solution I can think of is modifying your related xml layout. Please share that code if you think that it can a solution as well. – Kavach Chandra Aug 06 '17 at 22:48
  • @KavachChandra https://gist.github.com/anonymous/4e719684e4871100fd5ac007817f6762 – nicoqueijo Aug 06 '17 at 23:15
  • Please accept the answer if it works for you! :) – Kavach Chandra Aug 06 '17 at 23:35
  • Yes it worked thank you so much! I – nicoqueijo Aug 07 '17 at 00:12

1 Answers1

1

Based on the code in your xml file on github following changes need to be made to achieve the desired effect :

<LinearLayout
        android:id="@+id/container_buttons"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:baselineAligned="false"
        android:orientation="horizontal"
        android:layout_below="@+id/relativeLayout">

 .
 .
 .
 </LinearLayout>
<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:id="@+id/relativeLayout">

        <View
            android:id="@+id/horizontal_divider1"
            android:layout_width="wrap_content"
            android:layout_height="2dp"
            android:layout_centerInParent="true"
            android:background="@color/gray"
            android:layout_toLeftOf="@+id/more_info_label"
            android:layout_toStartOf="@+id/more_info_label"/>


        <TextView
            android:id="@+id/more_info_label"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:padding="5dp"
            android:text="@string/more_info"
            android:textSize="18dp" />

        <View
            android:id="@+id/horizontal_divider2"
            android:layout_width="wrap_content"
            android:layout_height="2dp"
            android:layout_centerInParent="true"
            android:background="@color/gray"
            android:layout_toRightOf="@+id/more_info_label"
            android:layout_toEndOf="@+id/more_info_label"/>

    </RelativeLayout>
Kavach Chandra
  • 770
  • 1
  • 10
  • 25