Q
如何让机器人
-6
A
回答
2
结交新类
ShapeMaker.class
public class ShapeMaker {
public ShapeMaker() {
}
public GradientDrawable circle (int backgroundColor, int borderColor, int storke, int radius) {
GradientDrawable shape = new GradientDrawable();
shape.setShape(GradientDrawable.RECTANGLE);
shape.setColor(backgroundColor);
shape.setStroke(storke, borderColor);
shape.setCornerRadius(radius);
return shape;
}
}
叫它
myLayout.setBackground(new ShapeMaker().circle(Color.BLUE, Color.BLACK, 1, 10));
编辑
布局例如:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:background="@android:color/holo_green_light"
tools:context="net.netbox4u.gradientcolor.MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:elevation="8dp"
android:text="Imagine"
android:textSize="30sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/shape_background"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"></LinearLayout>
</android.support.constraint.ConstraintLayout>
MainActivity例如:
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.LinearLayout;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LinearLayout shapeBackgroundLayout = (LinearLayout)findViewById(R.id.shape_background);
shapeBackgroundLayout.setBackground(new ShapeMaker().circle(Color.WHITE, Color.TRANSPARENT, 0, 50));
}
}
相关问题
- 1. 如何让机器人
- 2. 如何让机器人
- 3. 如何让机器人
- 4. 如何让机器人
- 5. 如何让机器人
- 6. 如何让机器人
- 7. 如何让机器人
- 8. 如何让机器人
- 9. 如何让这个机器人工作?
- 10. 机器人 - 如何让内所发生
- 11. 如何让机器人工作?
- 12. 如何让机器人的EditText列
- 13. 如何让机器人类型变成`:`?
- 14. CeeBot:让机器人倾斜
- 15. 机器人竞赛 - 我如何让多个机器人互相竞争
- 16. Finch让机器人发出声音
- 17. 如何实现机器人
- 18. 如何引导机器人
- 19. 如何实现机器人
- 20. 如何检索机器人
- 21. 如何实现机器人
- 22. 如何防止机器人
- 23. 机器人 - 如何片段
- 24. 如何实现机器人
- 25. 如何实现机器人
- 26. 如何实现机器人
- 27. 如何在机器人
- 28. 如何实现机器人
- 29. 如何在机器人
- 30. 如何让闲散的机器人离开渠道?
你想让它?酷... –
是的。也许我可怜的英语不会暴露我的想法。我想创建一个java类来绘制类似上面的视图,并且它在里面是透明的。我不知道我的问题出了什么问题? –
'我期望创造这个观点'我们也期望**你**创造它。或者至少要尝试。 –