• 8
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

This is the problem scenario:

I have an Activity including a ScrollView, ScrollView has only one LinearLayout as a child and the LinearLayout has one TextView. The XML file is here:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

    <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/bubble_shape"
                android:text="@string/TestLargeText"/>
        </LinearLayout>

    </HorizontalScrollView>

</LinearLayout>

and the "bubble_shape" drawable is here:

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <corners
        android:bottomLeftRadius="15dp"
        android:bottomRightRadius="15dp"
        android:topLeftRadius="15dp"
        android:topRightRadius="15dp"/>
    <padding
        android:bottom="12dp"
        android:left="12dp"
        android:right="12dp"
        android:top="12dp"/>
    <stroke
        android:width="8dp"
        android:color="#ff00ff"/>
</shape>

I have a large text in the TextView and here is the problem: when the TextView has large text the background shape is not showing. You can see the problem in the pictures below:

the xml file width small text

and the same xml width a large text!

how can I solve the problem?

      • 1
    • I copied your code into my IDE and did not have your issue. Maybe there is more going on here that you can share. As I cannot reproduce based on your code other than the width going off the screen.

I solved your problem in two ways .

1- set "bubble_shape" to your HorizontalScrollView

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/bubble_shape">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/TestLargeText" />
        </LinearLayout>

    </HorizontalScrollView>

</LinearLayout>

2- or just change corners tag in your "bubble_shape" like this :

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <corners android:radius="15dp" />        

    <padding
        android:bottom="12dp"
        android:left="12dp"
        android:right="12dp"
        android:top="12dp" />


    <stroke
        android:width="8dp"
        android:color="#ff00ff" />
</shape>
  • 1
Reply Report
      • 2
    • Tanks @mohammadReza about your first solution I should say in my case is not good enough because I'm going to add more TextViewes and I want them to be separate by the shape stroke. Your second solution solved my problem so amazingly and I still can't understand why this happens when I use radius for corners separately. Do you have any idea about that?
      • 1
    • dadash man harchi dar moredesh search zadam dalilesho nafahmidam! ag chizi dastam oomad too hamin post migam dalilesho ! zendebad finglish :)