我在哪里可以找到浮动动作按钮中心的加号?
它是由Android制作还是我需要自己做?
android material-design floating-action-button android-5.0-lollipop android-6.0-marshmallow
我正在使用包含带有TextView和ImageView的CardView的RecyclerView(每张卡代表一个城市).我在每张卡片上都有一个onClickListener,可以将我带到城市的博物馆列表中.(RecyclerView由ArrayList填充).该列表是由垂直滚动的同一Cardview组成的RecyclerView.
当一个城市只有一个博物馆时,如何在屏幕中央显示独特的CardView?
这是活动xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.bebbo203.mymuseum.MuseumActivity">
<android.support.v7.widget.RecyclerView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/recyclerViewMuseum"
android:scrollbars="vertical"
android:scrollIndicators="none"
android:gravity="center_horizontal"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这是RecyclerView xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
xmlns:card_view="http://schemas.android.com/apk/res-auto">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="150dp"
android:id="@+id/cardView"
card_view:cardCornerRadius="2dp"
card_view:cardUseCompatPadding="true"
android:gravity="center_horizontal"
android:animateLayoutChanges="true"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:id="@+id/imageViewList"
android:layout_gravity="center_horizontal|top"
android:adjustViewBounds="true"
android:scaleType="centerCrop"/>
<TextView
android:id="@+id/textViewList"
android:layout_width="match_parent"
android:layout_height="150dp"
android:textSize="40sp"
android:textIsSelectable="false"
android:textAlignment="center"
android:gravity="fill"
android:textStyle="bold"
android:layout_weight="1"
android:layout_gravity="center_horizontal|top"/>
</FrameLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>`
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助.
当我点击只有一个博物馆的Parigi时,我想在屏幕中央显示单个卡片视图
(如果有可能我想从屏幕中心开始,而不是从顶部开始.如果我打开活动时中央卡片视图始终位于中心.例如,在中心翻译NationalGallery另一个的顺序)
当我尝试使用InstantRun启动旧应用程序时,它说:
找不到模块应用程序的Gradle build-info.xml.请确保您使用的是gradle插件"2.0.0-alpha4"或更高版本.
我怎么解决这个问题?
我想制作一个简单的程序来提高我对这类编程的了解.我发现了一个非常有用的库,pyeasyGA,并且我尝试使用graphics.py创建一个简单的程序,从随机生成的"pass"序列创建一个收敛到一个点的序列.
这就是它的工作原理:
def create_individual(data):
a = [(randint(0,5),randint(0,5)) for n in range(len(data))]
print(a)
return a
Run Code Online (Sandbox Code Playgroud)
此函数创建一系列传递,因为graphics.py库允许您通过为对象移动它想要移动它来移动对象.那是我的"个人".
为了计算健身,我使用了这个:
def fitness(individual, data):
totX=0
totY=0
for elem in individual:
totX+=elem[0]
totY+=elem[1]
tot = (totX,totY)
return distEuclidea(arrivo, tot)
def distEuclidea(p1,p2):
x1 = p1[0]
y1 = p1[1]
x2 = p2[0]
y2 = p2[1]
return ((x2-x1)**2+(y2-y1)**2)**(1/2)
Run Code Online (Sandbox Code Playgroud)
此功能计算距所需到达点的距离.
在这些过程之后,程序会产生很多代,并且会使个体具有最低的适应度,但它不起作用.
它没有发展.每个传递序列似乎都是随机生成的.
有谁可以帮助我吗?
编辑:
该计划似乎有效.唯一的问题是几代人.