【发布时间】:2018-06-21 08:56:04
【问题描述】:
这是我的代码
var graphHeight = parentLayout.height
var graphPointView = LayoutInflater.from(context).inflate(R.layout.view_graph_point, null, false)
graphPointView.y =(graphHeight / 2f)
graphView.addView(graphPointView)
还有……
灰线在视图组布局的中心位置,为什么红点不在视图组布局的中心?我想把它放在中心位置。 (如灰线)
我的代码有什么问题?
view_graph_point.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/graph_point_view"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_centerHorizontal="true"
android:background="@drawable/graph_round_point"
xmlns:android="http://schemas.android.com/apk/res/android" />
graph_round_point.xml
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<solid android:color="#A04000"/>
<stroke android:width="1dp" android:color="#fff" />
<size android:width="12dp" android:height="12dp"/>
【问题讨论】:
-
显示你的
R.layout.view_graph_pointxml -
我添加了。 @洪端
-
是
graph_round_pointpng 或 shape drawable,如果 shape 则发布代码。也尝试在高度和宽度上使用 wrap_content。 -
和
@drawable/graph_round_point? -
我将高度和宽度更改为 wrap_content 。但图形点仍在灰线下方。 T.T.....请检查graph_round_point.xml