小编The*_*Way的帖子

在android xml中将按钮排列成菱形

我想创建一个带有四个按钮的屏幕,每个按钮都是一个钻石形状(就像一个方形转向45度),所有四个按钮都排成一个更大的钻石.

我在这里搜索了SO并设法创建了这个xml文件,提示我想要实现的目标:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/White"
android:orientation="vertical"
android:visibility="visible">


<TextView
    android:id="@+id/scoreCount"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge">

</TextView>


<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:adjustViewBounds="true"
    android:layout_weight="1.0" >


    <Button
        android:id="@+id/topLeftOuter"
        android:layout_centerInParent="true"
        android:layout_width="60dp"
        android:layout_height = "60dp"
        android:background="@color/Blue"
        android:clickable="true"
        android:visibility="visible"
        android:adjustViewBounds="true"
        android:rotation="45" >


    </Button>



</RelativeLayout>


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1.0"
    android:clickable="true">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        android:adjustViewBounds="true"
        android:layout_weight="1.0" >

    <Button
        android:id="@+id/bottomLeftOuter"
        android:layout_centerInParent="true"
        android:layout_width="60dp"
        android:layout_height = "60dp"
        android:background="@color/Yellow"
        android:clickable="true"
        android:visibility="visible"
        android:adjustViewBounds="true"
        android:rotation="45" >


    </Button>

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        android:adjustViewBounds="true"
        android:layout_weight="1.0" >

        <Button
            android:id="@+id/bottomRightOuter"
            android:layout_centerInParent="true"
            android:layout_width="60dp"
            android:layout_height = …
Run Code Online (Sandbox Code Playgroud)

java android android-layout

6
推荐指数
1
解决办法
1608
查看次数

将AWS documentDB附加到Spring Boot应用程序

我最近尝试在Spring应用程序中将新的AWS DocumentDB服务用作数据库。

群集已在与我在其上部署应用程序的EKS相同的VPC中创建。安全组允许VPC中所有节点之间的连接。

AWS为我的数据库集群公开了这样的mongo URI:

mongodb://<my-user>:<insertYourPassword>@<my-cluster-endpoint>:27017/?ssl_ca_certs=rds-combined-ca-bundle.pem&replicaSet=rs0
Run Code Online (Sandbox Code Playgroud)

我的问题:

如何使我的Spring代码与这种连接一起工作?

我尝试将followig添加到我的application.properties文件中:

spring.data.mongodb.uri=mongodb://<my-user>:<insertYourPassword>@<my-cluster-endpoint>:27017/admin?ssl_ca_certs=rds-combined-ca-bundle.pem&replicaSet=rs00
spring.data.mongodb.database=admin
server.ssl.key-store=classpath:rds-combined-ca-bundle.pem
Run Code Online (Sandbox Code Playgroud)

并将PEM文件放入 /src/main/resources

但是,该代码仍然无法连接到数据库集群。

我收到此消息是错误消息: No server chosen by com.mongodb.client.internal.MongoClientDelegate

跟一个 Exception in monitor thread while connecting to server ...

最后是超时异常: com.mongodb.MongoSocketReadTimeoutException: Timeout while receiving message

它看起来像是一个安全组问题,但我没有问题,可以从运行Spring应用程序Pod的同一EC2中连接mongo shell。

有任何想法吗?

spring amazon-web-services aws-documentdb-mongoapi

4
推荐指数
2
解决办法
2925
查看次数