Android 按y转换时,Listview被切断

Android 按y转换时,Listview被切断,android,xaml,listview,xamarin,xamarin.android,Android,Xaml,Listview,Xamarin,Xamarin.android,注意:这些是随机生成的地址 嘿,伙计们,我正在学习Xamarin,我正在尝试向下滚动我的框架布局,并显示我列表视图的搜索栏。以下是正在发生的事情: 我对我的版面进行了颜色编码,以查看尺寸是否存在问题,但我不认为存在问题,因为我的橙色版面足够容纳我的两个条目。对于这种应用程序,我是否使用了错误的布局?我将感谢任何帮助 这是我的翻译代码: frameLayout.Animate().TranslationYBy(editSearch.Height).SetDuration(500).Start(

注意:这些是随机生成的地址

嘿,伙计们,我正在学习Xamarin,我正在尝试向下滚动我的框架布局,并显示我列表视图的搜索栏。以下是正在发生的事情:

我对我的版面进行了颜色编码,以查看尺寸是否存在问题,但我不认为存在问题,因为我的橙色版面足够容纳我的两个条目。对于这种应用程序,我是否使用了错误的布局?我将感谢任何帮助

这是我的翻译代码:

frameLayout.Animate().TranslationYBy(editSearch.Height).SetDuration(500).Start();
和我的布局文件:

<android.support.v4.widget.SwipeRefreshLayout 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:id="@+id/swipeLayout">
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:maxHeight="100dp"
        android:id="@+id/frameLayoutParent"
        android:background="@android:color/holo_green_dark">
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/frameLayout"
        android:background="@android:color/holo_green_light">
        <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:minHeight="300dp"
                android:background="@android:color/holo_orange_light">
                <Button
                    android:text="Add New Address"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/addNewAddress"
                    android:maxHeight="20dp" />
                </LinearLayout>
        <ListView
            android:paddingTop="50dp"
            android:minWidth="25px"
            android:minHeight="300dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/myListView"
            android:maxHeight="300dp"/>
    </FrameLayout>
<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/editSearch"
    android:hint="Search ZipCodes"
    android:textColor="#000"/>
</FrameLayout>
</android.support.v4.widget.SwipeRefreshLayout>
正在学习Xamarin,我正在尝试向下滚动我的框架布局,并显示我的列表视图的搜索栏。以下是正在发生的事情:

我使用您的代码进行测试,但在SwipeRefreshLayout\uu刷新事件中Y进行翻译时没有问题

 public class MainActivity : AppCompatActivity
{
    string[] items;
    ListView listview1;
    SwipeRefreshLayout swiplayout;
    FrameLayout framelayout;
    EditText edittext;
    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
        Xamarin.Essentials.Platform.Init(this, savedInstanceState);
        // Set our view from the "main" layout resource
        SetContentView(Resource.Layout.activity_main);
        listview1 = FindViewById<ListView>(Resource.Id.myListView);
        swiplayout = FindViewById<SwipeRefreshLayout>(Resource.Id.swipeLayout);
        framelayout = FindViewById<FrameLayout>(Resource.Id.frameLayout);
        edittext = FindViewById<EditText>(Resource.Id.editSearch);
        swiplayout.Refresh += Swiplayout_Refresh;
        items = new string[] { "Vegetables", "Fruits", "Flower Buds", "Legumes", "Bulbs", "Tubers" };
        listview1.Adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, items);
    }

    private void Swiplayout_Refresh(object sender, EventArgs e)
    {
        framelayout.Animate().TranslationYBy(edittext.Height).SetDuration(500).Start();
    }

  
}
public类main活动:AppCompatActivity
{
字符串[]项;
列表视图列表视图1;
SwipeRefreshLayout swiplayout;
框架布局框架布局;
编辑文本编辑文本;
创建时受保护的覆盖无效(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(这个,savedInstanceState);
//从“主”布局资源设置视图
SetContentView(Resource.Layout.activity_main);
listview1=FindViewById(Resource.Id.myListView);
swiplayout=findviewbyd(Resource.Id.swipeLayout);
framelayout=findviewbyd(Resource.Id.framelayout);
edittext=findviewbyd(Resource.Id.editSearch);
swiplayout.Refresh+=swiplayout\u Refresh;
items=新字符串[]{“蔬菜”、“水果”、“花蕾”、“豆类”、“鳞茎”、“块茎”};
listview1.Adapter=new ArrayAdapter(这个,Android.Resource.Layout.SimpleListItem1,项目);
}
私有void播放\刷新(对象发送方、事件参数e)
{
framelayout.Animate().translationBy(edittext.Height).SetDuration(500.Start();
}
}
这是我的截图:

如果您想过滤ListView,我建议您可以使用工具栏中的SearchView来过滤ListView数据,请查看此示例:


嗯,我把我的翻译代码放在我的刷新活动中,它和你的一样完美。当我将其放入
OnOptionsItemSelected
函数时,会发生错误。它由操作栏中的按钮触发。当我添加
editSearch.Animate().AlphaBy(1.0f).SetDuration(500).Start()时,我用我的
OnOptionsItemSelected
function的代码编辑了我的文章与我的翻译一致,它做得很好,可能只是删除我的动画类,并使用与translation@mrgucci你现在解决了你的问题?如果是,请记住,如果我的回答对您有帮助,请将我的回答标记为答案。
 public class MainActivity : AppCompatActivity
{
    string[] items;
    ListView listview1;
    SwipeRefreshLayout swiplayout;
    FrameLayout framelayout;
    EditText edittext;
    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
        Xamarin.Essentials.Platform.Init(this, savedInstanceState);
        // Set our view from the "main" layout resource
        SetContentView(Resource.Layout.activity_main);
        listview1 = FindViewById<ListView>(Resource.Id.myListView);
        swiplayout = FindViewById<SwipeRefreshLayout>(Resource.Id.swipeLayout);
        framelayout = FindViewById<FrameLayout>(Resource.Id.frameLayout);
        edittext = FindViewById<EditText>(Resource.Id.editSearch);
        swiplayout.Refresh += Swiplayout_Refresh;
        items = new string[] { "Vegetables", "Fruits", "Flower Buds", "Legumes", "Bulbs", "Tubers" };
        listview1.Adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, items);
    }

    private void Swiplayout_Refresh(object sender, EventArgs e)
    {
        framelayout.Animate().TranslationYBy(edittext.Height).SetDuration(500).Start();
    }

  
}