Android添加垂直滚动scrollview
2019獨角獸企業重金招聘Python工程師標準>>>
需求 :界面內容太多,為了方便查看,就在linearlayout添加scrollview
?eg:
???<?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:orientation="vertical"??
????????android:layout_width="fill_parent"??
????????android:layout_height="fill_parent"??
????????tools:context=".MainActivity">??
?</LinearLayout>?
---------------添加滾動后-------------------------------------------------------------------
<?xml?version="1.0"?encoding="utf-8"?>???
<ScrollView????
????????xmlns:android="http://schemas.android.com/apk/res/android"??
????????xmlns:tools="http://schemas.android.com/tools"??
????????android:layout_width="fill_parent"????
???????android:layout_height="fill_parent"????
???????android:scrollbars="vertical"????
????????android:fadingEdge="vertical">??
????<LinearLayout??
????????xmlns:android="http://schemas.android.com/apk/res/android"??
????????xmlns:tools="http://schemas.android.com/tools"??
????????android:orientation="vertical"??
????????android:layout_width="fill_parent"??
????????android:layout_height="fill_parent"??
????????tools:context=".MainActivity">??
????</LinearLayout>??
</ScrollView>??
----------------------異常---------------------------------------------------------------
Unexpected namespace prefix "xmlns" found for tag LinearLayout
----------------------解決方法-----------------------------------------------------------
xmlns:android="http://schemas.android.com/apk/res/android"??必須作為第一個節點的屬性,于是把LinearLayout的xmlns:android和xmlns:tools這兩個屬性去掉就可以了
----------------------結果---------------------------------------------------------------
? xmlns:android="http://schemas.android.com/apk/res/android"<?xml?version="1.0"?encoding="utf-8"?>???
???<ScrollView????
???????????xmlns:android="http://schemas.android.com/apk/res/android"??
????????????xmlns:tools="http://schemas.android.com/tools"??
?????????????android:layout_width="fill_parent"????
?????????????android:layout_height="fill_parent"????
?????????????android:scrollbars="vertical"????
??????????????android:fadingEdge="vertical">??
????????<LinearLayout??
??????????????android:orientation="vertical"??
??????????????android:layout_width="fill_parent"??
?????????????android:layout_height="fill_parent"??
??????????????tools:context=".MainActivity">??
?????</LinearLayout>??
????</ScrollView>??
轉載于:https://my.oschina.net/u/1792000/blog/361531
總結
以上是生活随笔為你收集整理的Android添加垂直滚动scrollview的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 浅谈Junit测试中反射和Jmock的应
- 下一篇: Android ProgressBar