Android 滚动查看通过不显示最后一项来平滑滚动
XML更新Android 滚动查看通过不显示最后一项来平滑滚动,android,xamarin,xamarin.android,android-scrollview,Android,Xamarin,Xamarin.android,Android Scrollview,XML更新 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="100">
<!--App Bar Layout Pane-->
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="7"
android:background="@drawable/AppBarBackground"
android:weightSum="100">
<!--Unrelated XML Code-->
</LinearLayout>
<!--App Bar Layout Pane end-->
<!--Body Pane-->
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="93"
android:weightSum="100"
android:background="@drawable/AppBackground">
<!--Left Pane-->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="37"
android:background="@color/whiteWithAlpha75">
<!--Unrelated XML Code-->
</LinearLayout>
<!--Left Pane end-->
<!--Right Pane-->
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="43">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="100">
<!--Right Pane Header-->
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="8"
android:weightSum="100"
android:background="@color/whiteWithAlpha10"
android:paddingLeft="15dp"
android:paddingRight="15dp">
<TextView
android:text="Item(s)"
android:fontFamily="@string/fontFamily"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="24"
android:textColor="@color/grayDark"
android:gravity="center|left"
android:textSize="@dimen/textSizeXSmall" />
<TextView
android:text="Unit Price"
android:fontFamily="@string/fontFamily"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="17"
android:textColor="@color/grayDark"
android:gravity="center"
android:textSize="@dimen/textSizeXSmall" />
<TextView
android:text="Quantity"
android:fontFamily="@string/fontFamily"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="28"
android:textColor="@color/grayDark"
android:gravity="center"
android:textSize="@dimen/textSizeXSmall" />
<TextView
android:text="Discount"
android:fontFamily="@string/fontFamily"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="16"
android:textColor="@color/grayDark"
android:gravity="center"
android:textSize="@dimen/textSizeXSmall" />
<TextView
android:text="Total"
android:fontFamily="@string/fontFamily"
android:gravity="center|right"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="15"
android:textColor="@color/grayDark"
android:textSize="@dimen/textSizeXSmall" />
</LinearLayout>
<!--Right Pane Header end-->
<!--Right Pane Item Selected-->
<android.support.v4.widget.NestedScrollView
android:id="@+id/scrollItemSelectedArea"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="92"
android:paddingBottom="5dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:background="@color/whiteWithAlpha15">
<LinearLayout
android:id="@+id/llItemSelectedArea"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp" />
</android.support.v4.widget.NestedScrollView>
<!--Right Pane Item Selected end-->
<!--Right Pane Functions-->
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="39"
android:weightSum="100">
<!--Unrelated XML Code-->
</LinearLayout>
<!--Right Pane Functions end-->
</LinearLayout>
</FrameLayout>
<!--Right Pane end-->
</LinearLayout>
<!--Body Pane end-->
</LinearLayout>
使用ScrollView显示xml代码我更新了代码,删除了一些不相关的xml代码。有些保留供其他人检查布局重量。将其添加到ScrollView并检查其是否工作android:fillViewport=“true”然后我尝试将NestedScrollVIew更改为ScrollView,因为嵌套视图中不存在fillViewport。但问题仍然存在。最后一项仍然在屏幕底部隐藏。ScrollView只从上次滚动到第二项我不知道这是否是一个好答案,但我通过在线性布局中添加paddingBottom解决了这个问题。
public void renderItemSelected(ENT_TransactionItems entityTransactionItem, string displayName)
{
entityTransactionItemList.Add(entityTransactionItem);
View vNewView = activity.LayoutInflater.Inflate(Resource.Layout.Layout_ItemSelected, llItemSelected, false);
TextView tvItemName = vNewView.FindViewById<TextView>(Resource.Id.tvItemName);
TextView tvItemAmount = vNewView.FindViewById<TextView>(Resource.Id.tvItemPrice);
EditText etItemQuantity = vNewView.FindViewById<EditText>(Resource.Id.tvItemQuantity);
Button btnDiscount = vNewView.FindViewById<Button>(Resource.Id.btnDiscount);
TextView tvTotal = vNewView.FindViewById<TextView>(Resource.Id.tvTotal);
//other code
llItemSelected.AddView(vNewView);
viewList.Add(vNewView);
scrollItemSelectedArea.SmoothScrollBy(0, llItemSelected.Height);
}