我想在背景中创建方形。 Android studio shape不支持square.How如何在border.xml中手动创建?
这是我的代码
border.xml
bundle --without every other group
my.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#9294a3" />
<stroke
android:width="2dp"
android:color="#c2bbbb" />
<corners android:radius="2dp" />
</shape>
答案 0 :(得分:1)
<强> XML 强>
<TextView
android:layout_width="150dp"
android:layout_height="150dp"
android:background="@drawable/border"
android:text="2"
android:textSize="50sp"
android:gravity="center"
android:textColor="#ffffff"
android:padding="5dp"/>
样式(drawable / border.xml)
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/colorGray"/>
<stroke android:color="@color/colorBlack"
android:width="4dp" />
<!--corners allow us to make the rounded corners button-->
<corners android:radius="15dp" />
</shape>
</item>
</selector>
答案 1 :(得分:0)
你应该指定shape =&#39;矩形&#39;对于广场来说会更好。
* {
box-sizing: border-box;
}
.outer-main{
display: inline-block;
position: relative;
}
.outer {
position: relative;
padding: 10px;
border: solid 1px black;
background-color: orange;
width: 400px;
height: 200px;
overflow-x: scroll;
overflow-y: hidden;
}
.stay-right {
position: absolute;
right: -19px;
top: 0px;
border: solid 1px black;
background-color: green;
width: 20px;
height:100%;
z-index: 1
}
.inner {
width: 600px;
}
答案 2 :(得分:0)
<TextView
android:id="@+id/input_name"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="right"
android:direction="center"
android:gravity="center"/>