[英]Cant view anything(textviews) inside scroll view
I am unable to see anything (the textviews) after building the app. 构建应用程序后,我看不到任何内容(textviews)。 Only the background image is showing up and nothing else.Tried everything but still the texts doesn't show up. 仅显示背景图片,没有其他内容。尝试了所有操作,但仍未显示文本。 Under the scrollview i make a linear layout and under that there are several other textviews.But none of them are actually showing up when i am building the app. 在滚动视图下,我进行了线性布局,在该视图下还有其他几个文本视图。但是当我构建应用程序时,它们实际上都没有显示出来。 How can i make everything under the scrollview visible? 如何使滚动视图下的所有内容可见? Here's my code: 这是我的代码:
` `
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/blck"
android:weightSum="1"
tools:context="com.gnulinuxusersgroup.nitdgp.glug.faqs"
app:layout_collapseParallaxMultiplier="1.0">
<!-- TODO: Update blank fragment layout -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="75dp"
android:id="@+id/F"
tools:text="@string/faq"
tools:textColor="#ffffff"
tools:textSize="100px"
android:textAppearance="@style/TextAppearance.AppCompat"
android:layout_weight="0.02" />
<TextView
android:layout_width="match_parent"
android:layout_height="130px"
tools:text="@string/hwr"
tools:textColor="#fff"
tools:textSize="40px"
tools:textStyle="bold"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="300px"
tools:text="@## `string/hwr2"
tools:textColor="#fff"
tools:textSize="40px"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="130px"
tools:text="@string/foss"
tools:textColor="#fff"
tools:textSize="40px"
tools:textStyle="bold"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="269dp"
tools:text="@string/foss2"
tools:textColor="#fff"
tools:textSize="40px" />
<TextView
android:layout_width="match_parent"
android:layout_height="130px"
tools:text="@string/work1"
tools:textColor="#fff"
tools:textSize="40px"
tools:textStyle="bold"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="300px"
tools:text="@string/work2"
tools:textColor="#fff"
tools:textSize="40px"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="130px"
tools:text="@string/free"
tools:textColor="#fff"
tools:textSize="40px"
tools:textStyle="bold"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="300px"
tools:text="@string/free2"
tools:textColor="#fff"
tools:textSize="40px"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="46dp"
tools:text="@string/git"
tools:textColor="#fff"
tools:textSize="40px"
tools:textStyle="bold"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="300px"
tools:text="@string/git2"
tools:textColor="#fff"
tools:textSize="40px"
/>
<TextView
android:layout_width="394dp"
android:layout_height="50dp"
tools:text="@string/gsoc"
tools:textColor="#fff"
tools:textSize="40px"
tools:textStyle="bold"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="700px"
tools:text="@string/gsoc2"
tools:textColor="#fff"
tools:textSize="40px"
/>
</LinearLayout>
</ScrollView>
` `
Replace your various tools:
attributes with android:
attributes. 用android:
属性替换各种tools:
android:
属性。
The tools
namespace is used only by the Android Studio design preview window. tools
名称空间仅由Android Studio设计预览窗口使用。 This allows you to do things like specify placeholder text so that you can see what it would look like... without specifyiing actual user-visible text that might incorrectly appear in the real world. 这使您可以执行诸如指定占位符文本的操作,以便可以看到它的外观...而无需指定可能在现实世界中错误显示的实际用户可见文本。
Take this TextView: 采取以下TextView:
<TextView
android:layout_width="match_parent"
android:layout_height="130px"
tools:text="@string/hwr"
tools:textColor="#fff"
tools:textSize="40px"
tools:textStyle="bold"
/>
Because all of the last four attributes use the tools
namespace, they will not actually have any effect when you run the app. 由于后四个属性全部使用tools
名称空间,因此当您运行应用程序时,它们实际上不会产生任何作用。 This is the same as having written this (as far as your running app is concerned): 这与编写此代码相同(就您正在运行的应用程序而言):
<TextView
android:layout_width="match_parent"
android:layout_height="130px"
/>
For now, just replace all the tools
namespaces with android
: 现在,只需将所有tools
名称空间替换为android
:
<TextView
android:layout_width="match_parent"
android:layout_height="130px"
android:text="@string/hwr"
android:textColor="#fff"
android:textSize="40px"
android:textStyle="bold"
/>
Adding to the Ben P's answer, the possible culprits are: 除Ben P的答案外,可能的罪魁祸首是:
layout_height="0dp"
in case of horizontal orientation have width as 0dp. 由于LinearLayout的方向为“垂直”,并且您使用权重总和时,最好在水平方向的情况下将layout_height="0dp"
宽度设置为0dp。 layout_weight
adds up to the value, you can omit the weightsum by which system calculates percentages automatically by considering individual weights of widgets in group. 如果指定权重总和,请确保layout_weight
等于该值,则可以忽略权重总和,系统将通过考虑组中各个小部件的权重来自动计算百分比。 Also as the widgets are textview you can't see much difference in vertical orientation so i have changed the below xml orientation to horizontal so that while running on device or in the layout preview window you can see the weight difference clearly. 另外,由于小部件是textview,因此您在垂直方向上看不到太多差异,因此我将下面的xml方向更改为水平,因此在设备上或在布局预览窗口中运行时,您可以清楚地看到重量差异。
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/F" android:text="hello1" android:textSize="60px" android:textAppearance="@style/TextAppearance.AppCompat" android:layout_weight="1" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="hello1r" android:textSize="40px" android:textStyle="bold" android:layout_weight="4" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="hello3" android:layout_weight="1" android:textSize="40px" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="hello4" android:layout_weight="2" android:textSize="40px" android:textStyle="bold" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="2" android:text="hello5" android:textSize="40px" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.