在我的布局中,我有2个textview水平相同的重量和约束布局,但我希望那些textview具有不同重量的6:4比例.
那么如何使用约束布局在我的布局中实现这一点.
我对TextView有一个奇怪的问题,它在最后切断了部分文本.我的布局看起来像
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top|center_horizontal"
android:gravity="top|center_horizontal"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top|center_horizontal"
android:gravity="top|center_horizontal"
android:orientation="horizontal"
android:layout_weight="1"
android:layout_marginBottom="5dp">
<Button
android:id="@+id/btnPreviousQuestion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/selector_arrow_left"
android:clickable="true"
android:visibility="gone" >
</Button>
<TextView
android:id="@+id/txtQuestion"
style="@style/question_text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="top|center_horizontal"
android:layout_weight="1"
/>
<Button
android:id="@+id/btnNextQuestion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:background="@drawable/selector_arrow_right"
android:clickable="true" >
</Button>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:orientation="horizontal" >
<WebView
android:id="@+id/wvMultimediaQuestion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginLeft="50dp"
android:layout_marginRight="55dp"
android:layout_weight="1"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
和txtQuestion在文本足够长时切断文本.有什么不对,有人知道吗?
我不确定它只是"最后一行",但我们有一个带有fill_parent宽度,wrap_content高度的TextView的应用程序.文本正在从Java代码中动态放入.即使布局中有足够的空间,文本的最后一行也没有显示出来.它在一个相当深的视图层次结构内部,所以我的猜测是它的测量逻辑变得混乱,但它非常令人沮丧.我们需要猜测文本中有多少行,并相应地设置'android:lines'以使其工作.
有谁见过这个?在代码中,请参见底部的id'contentTextView'.如果我拿出'android:lines',最后一行文字就会消失.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/flag"
>
<include android:id="@+id/incHeader" layout="@layout/header"/>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView
android:layout_width="fill_parent"
android:layout_height="101dp"
android:background="@drawable/headershadow"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_weight="1"/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="101dp"
android:background="@drawable/footershadow"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/gybcontentback"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<include android:id="@+id/gybHeaderInclude" layout="@layout/gybcontentheader"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#4f4f4f"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:lines="9"
android:id="@+id/contentTextView"/>
<ImageView
android:layout_marginTop="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/button_blue_rascal_button"
android:id="@+id/buttonMoreInfo"/>
</LinearLayout>
</FrameLayout>
<include android:id="@+id/incFooter" layout="@layout/menu"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
Java代码.我在onCreate期间使用标准Java字符串填充TextView.
@Override
protected String body()
{
return "Rascal Flatts and The Jason Foundation, Inc. …Run Code Online (Sandbox Code Playgroud) 我有一个 ViewPager 项目,它看起来像这样:
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:paddingLeft="@dimen/material_horizontal_margin"
android:paddingRight="@dimen/material_horizontal_margin"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/group_footer_pager_item_info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left"/>
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)
TextView 的文本可能很长,但它的长度真的无关紧要,因为在任何情况下,如果它足够大可以滚动——文本的最后一行根本不可见。
这可能是什么原因?