Wrap long text in alternate version dropdown (#5120)
This commit is contained in:
parent
ec148b0a23
commit
c4948cc455
@ -15,6 +15,7 @@ import android.text.style.ForegroundColorSpan;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
@ -476,8 +477,17 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
||||
for (String url : alternateFeedUrls.keySet()) {
|
||||
alternateUrlsTitleList.add(alternateFeedUrls.get(url));
|
||||
}
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, alternateUrlsTitleList);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
|
||||
R.layout.alternate_urls_item, alternateUrlsTitleList) {
|
||||
@Override
|
||||
public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||
// reusing the old view causes a visual bug on Android <= 10
|
||||
return super.getDropDownView(position, null, parent);
|
||||
}
|
||||
};
|
||||
|
||||
adapter.setDropDownViewResource(R.layout.alternate_urls_dropdown_item);
|
||||
viewBinding.alternateUrlsSpinner.setAdapter(adapter);
|
||||
viewBinding.alternateUrlsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
|
8
app/src/main/res/layout/alternate_urls_dropdown_item.xml
Normal file
8
app/src/main/res/layout/alternate_urls_dropdown_item.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<CheckedTextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/text1"
|
||||
style="?android:attr/spinnerDropDownItemStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingVertical="8dp" />
|
9
app/src/main/res/layout/alternate_urls_item.xml
Normal file
9
app/src/main/res/layout/alternate_urls_item.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/text1"
|
||||
style="?android:attr/spinnerItemStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="3"
|
||||
android:textAlignment="inherit" />
|
@ -118,6 +118,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:dropDownWidth="match_parent"
|
||||
android:padding="8dp"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="@dimen/text_size_micro" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user