Привет, ребята, у меня проблема.
Я использую градиентный оттенок для фона TextView, если текстовое представление имеет не много строк, которые оно работает, но если у него много строк, у меня отсутствует фон, TextView становится прозрачным.
Я вижу эту проблему на Android 7, также она работает на Android 4.4.2 ...
посмотрите на скриншоты, это точная ситуация.
как это исправить? Мне нужен GradientDraweable из-за угловых радиусов.
это полный код тестового приложения
public class MainActivity extends AppCompatActivity {
String testText1="a\n" +
"a\n" +
"a\n" +
"a\n" +
"a\n" +
"a\n" +
"a\n" +
"a";
String testText2="b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b\n" +
"b";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ScrollView root=new ScrollView(this);
TextView testWorking=new TextView(this);
testWorking.setTextColor(Color.BLACK);
testWorking.setTextSize(TypedValue.COMPLEX_UNIT_DIP,16);
testWorking.setText(testText1);
TextView testNotWorking=new TextView(this);
testNotWorking.setTextColor(Color.BLACK);
testNotWorking.setTextSize(TypedValue.COMPLEX_UNIT_DIP,16);
testNotWorking.setText(testText2);
GradientDrawable testBG=new GradientDrawable();
float chat_msgOut_each_corner_radi[] = {20f,20f, 20f,20f, 20f,20f, 20f,20f};
testBG.setCornerRadii(chat_msgOut_each_corner_radi);
testBG.setStroke(10, Color.TRANSPARENT);
testBG.setColor(Color.BLUE);
testWorking.setBackground(testBG);
testWorking.setGravity(Gravity.CENTER);
testNotWorking.setBackground(testBG);
testNotWorking.setGravity(Gravity.CENTER);
LinearLayout ll=new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
ll.addView(testWorking);
ll.addView(testNotWorking);
root.addView(ll);
setContentView(root);
}
спасибо.