我怎样才能在 android 中获得这种文本视图
How can i get this kind of textview in android
有什么方法可以得到这种 textview 吗,我已经使用过 view,但是由于我的 textview 高度随文本量而变化,我无法在 xml 或 java,因此view无法获取textview的所有高度
有解决办法吗??
我用this.But不行...
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:textSize="25sp"
android:textStyle="bold"
android:layout_gravity="center"/>
<RelativeLayout
android:id="@+id/viewp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@+id/title">
<TextView
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="7dp"
android:padding="5dp"
android:textSize="16sp"
android:text="hjdbcefc jc qec jcjejqf cmdn dchhwe c,we djh \n uydcvubcubcbwhchb"
/>
<View
android:id="@+id/view"
android:layout_width="5dp"
android:layout_height="match_parent" <!--if I use here like 20dp, it shows otherwise not-->
android:layout_alignParentStart="true"
android:background="@android:color/darker_gray" />
</RelativeLayout>
在@shadow 的帮助下我找到了这个解决方案
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="15dp"
android:textSize="25sp"
android:textStyle="bold"
android:layout_gravity="center"
android:text="Be Greatful to you creator"
/>
<LinearLayout
android:id="@+id/viewp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@+id/title"
android:layout_marginTop="10dp">
<View
android:id="@+id/view"
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_marginStart="10dp"
android:background="@android:color/darker_gray" />
<TextView
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="23dp"
android:padding="5dp"
android:textSize="16sp"
android:textStyle="italic"
android:text="Adults who frequently feel grateful have more energy, more optimism, more social connections and more happiness than those who do not, according to studies conducted over the past decade. They’re also less likely to be depressed, envious, greedy or alcoholics. They earn more money, sleep more soundly, exercise more regularly and have greater resistance to viral infections."
/> </LinearLayout>
有什么方法可以得到这种 textview 吗,我已经使用过 view,但是由于我的 textview 高度随文本量而变化,我无法在 xml 或 java,因此view无法获取textview的所有高度
有解决办法吗?? 我用this.But不行...
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:textSize="25sp"
android:textStyle="bold"
android:layout_gravity="center"/>
<RelativeLayout
android:id="@+id/viewp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@+id/title">
<TextView
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="7dp"
android:padding="5dp"
android:textSize="16sp"
android:text="hjdbcefc jc qec jcjejqf cmdn dchhwe c,we djh \n uydcvubcubcbwhchb"
/>
<View
android:id="@+id/view"
android:layout_width="5dp"
android:layout_height="match_parent" <!--if I use here like 20dp, it shows otherwise not-->
android:layout_alignParentStart="true"
android:background="@android:color/darker_gray" />
</RelativeLayout>
在@shadow 的帮助下我找到了这个解决方案
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="15dp"
android:textSize="25sp"
android:textStyle="bold"
android:layout_gravity="center"
android:text="Be Greatful to you creator"
/>
<LinearLayout
android:id="@+id/viewp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@+id/title"
android:layout_marginTop="10dp">
<View
android:id="@+id/view"
android:layout_width="5dp"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_marginStart="10dp"
android:background="@android:color/darker_gray" />
<TextView
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="23dp"
android:padding="5dp"
android:textSize="16sp"
android:textStyle="italic"
android:text="Adults who frequently feel grateful have more energy, more optimism, more social connections and more happiness than those who do not, according to studies conducted over the past decade. They’re also less likely to be depressed, envious, greedy or alcoholics. They earn more money, sleep more soundly, exercise more regularly and have greater resistance to viral infections."
/> </LinearLayout>