2017-08-21 44 views
0

長方體圓形按鈕是android中的自定義圓形按鈕(來源:Github Cuboid Circle Button)。在運行時更改長方體圓形按鈕顏色

我在我的應用程序中使用該按鈕。它運行良好,但我找不到在運行時以編程方式更改其顏色的方法。

在此類中,onCreate之前我有:

com.cuboid.cuboidcirclebutton.CuboidButton btnReplayEnd;

然後在onCreate

btnReplayEnd = (com.cuboid.cuboidcirclebutton.CuboidButton) findViewById(R.id.btnReplayEnd);

而在 'setTheme' 方法(在相同的類):

btnReplayEnd.setCircle_color(getResources().getColor(R.color‌.replayNormalDark));

回答

0

沒有辦法改變使用com.cuboid.cuboidcirclebutton.CuboidButton編程的circler顏色,你只能通過XML改變它app:cub_color="@color/color_03A9F4" 這樣

<com.cuboid.cuboidcirclebutton.CuboidButton 
      android:layout_width="120dp" 
      android:layout_height="120dp" 
      android:layout_centerInParent="true" 
      android:text="No Border" 
      android:textColor="#000000" 
      android:textSize="18sp" 
      app:cub_border_radius="0dp" 
      app:cub_color="@color/color_03A9F4" 
      app:cub_fontstyle="fonts/Bellerose.ttf" 
      app:cub_hover_color="#00BFFF1" 
      />