我正在非常努力地理解ScrollView和Linearlayout,并不断尝试在我的活动中使用它,但是我遇到了此错误。.我已经只有一个Linearlyout滚动视图内部,并且其他子项都包裹在包裹内容中和宽度,但应用仍然崩溃。.请帮助
import asyncio
from proxybroker import Broker
def get_random_proxy():
"""
Get random proxy from 'proxies.txt'.
"""
lines = open('proxies.txt').read().splitlines()
rproxy =random.choice(lines)
PROXY = rproxy
async def save(proxies, filename):
"""
Save proxies to a file.
"""
with open(filename, 'w') as file:
while True:
proxy = await proxies.get()
if proxy is None:
break
# Check accurately if the proxy is working.
if proxy.is_working:
protocol = 'https' if 'HTTPS' in proxy.types else 'http'
line = '{protocol}://{proxy.host}:{proxy.port}\n'
file.write(line)
def main():
proxies = asyncio.Queue()
broker = Broker(proxies)
tasks = asyncio.gather(broker.find(types=['HTTP', 'HTTPS'], limit=5),
save(proxies, filename='proxies.txt'))
loop = asyncio.get_event_loop()
loop.run_until_complete(tasks)
if __name__ == '__main__':
main()
谢谢。
答案 0 :(得分:1)
像这样,在ScrollView中只需要一个孩子即可。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView ... />
<TextView ... />
<TextView ... />
<TextView ... />
</LinearLayout>
</ScrollView>
答案 1 :(得分:0)
否,您在LinearLayout中有一个SrollView。您的ScrollView中只有一堆TextView。更改为此:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#ffffff"
tools:context=".Blood">
<TextView
android:layout_width="wrap_content"
android:layout_height="56dp"
android:textStyle="bold"
android:background="#f4051d"
android:textAlignment="center"
android:textColor="#ffffff"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Blood Type: Facts and Information"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#ffffff"
android:padding="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/intro"
android:layout_width="wrap_content"
android:layout_marginTop="15dp"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="#000000"
android:fontFamily="sans-serif-condensed"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="When "/>
<TextView
android:layout_width="wrap_content"
android:layout_marginTop="15dp"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="#0e06f2"
android:fontFamily="sans-serif-condensed"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Blood Types ( Groups )"/>
<TextView
android:id="@+id/blood_types"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:fontFamily="sans-serif-condensed"
android:text="A blood "
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"
android:textStyle="bold" />
<ImageView
android:id="@+id/image_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/drawable_blood_one"/>
<TextView
android:id="@+id/blood_type_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:fontFamily="sans-serif-condensed"
android:text="In addition ."
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_marginTop="15dp"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="#0e06f2"
android:fontFamily="sans-serif-condensed"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Donating Blood By Compatible Type"/>
<TextView
android:id="@+id/donate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:fontFamily="sans-serif-condensed"
android:text="Blood "
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"
android:textStyle="bold" />
<ImageView
android:id="@+id/image_two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/drawable_blood_two"/>
<TextView
android:layout_width="wrap_content"
android:layout_marginTop="15dp"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="#0e06f2"
android:fontFamily="sans-serif-condensed"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Finding Out Your Blood Type"/>
<TextView
android:id="@+id/find_blood_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:fontFamily="sans-serif-condensed"
android:text="It is easy "
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"
android:textStyle="bold" />
<ImageView
android:id="@+id/image_three"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/drawable_blood_three"/>
<TextView
android:id="@+id/find_blood_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:fontFamily="sans-serif-condensed"
android:text="In most"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_marginTop="15dp"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="#0e06f2"
android:fontFamily="sans-serif-condensed"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="What Does Blood Group RH Factor Mean"/>
<TextView
android:id="@+id/rh_factor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:fontFamily="sans-serif-condensed"
android:text="RH factor ."
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_marginTop="15dp"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="#0e06f2"
android:fontFamily="sans-serif-condensed"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="What is the Rarest Blood Type"/>
<TextView
android:id="@+id/rare_blood"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:fontFamily="sans-serif-condensed"
android:text="According "
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_marginTop="15dp"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="#0e06f2"
android:fontFamily="sans-serif-condensed"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Blood Type Diet"/>
<TextView
android:id="@+id/blood_type_diet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:fontFamily="sans-serif-condensed"
android:text=" The Ea"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_marginTop="15dp"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="#0e06f2"
android:fontFamily="sans-serif-condensed"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Blood Types and Personality"/>
<TextView
android:id="@+id/personality"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:fontFamily="sans-serif-condensed"
android:text="Legend"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_marginTop="15dp"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="#0e06f2"
android:fontFamily="sans-serif-condensed"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Facts: Blood Types"/>
<TextView
android:id="@+id/facts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:fontFamily="sans-serif-condensed"
android:text="Blood"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"
android:textStyle="bold" />
</LinearLayout>
</ScrollView>
</LinearLayout>