我已经在我的linux机器上配置了热敏打印机(ESC/POS)并使用终端命令(作为root)我可以打印它:
echo "Hello!" > /dev/usb/lp0
Run Code Online (Sandbox Code Playgroud)
但是,在golang中执行相同的过程没有任何反应:
package main
import (
"fmt"
"os"
)
func main() {
fmt.Println("Hello Would!")
f, err := os.Open("/dev/usb/lp0")
if err != nil {
panic(err)
}
defer f.Close()
f.Write([]byte("Hello world!"))
}
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我正在尝试在底部导航菜单顶部创建一个带有 FAB 的布局,但菜单始终位于按钮上方。:(
我的layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:id="@+id/container"
tools:context="com.example.mytest.money.MainActivity">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_margin="10dp"
android:layout_height="110dp"
android:padding="15dp"
card_view:cardElevation="2dp"
card_view:cardCornerRadius="4dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Test" />
</android.support.v7.widget.CardView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom_navigation"
android:layout_alignParentTop="true"
android:foreground="@color/colorBackground">
</ScrollView>
<com.aurelhubert.ahbottomnavigation.AHBottomNavigation
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:selectedBackgroundVisible="false"
android:layout_gravity="bottom" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/create_gain_expense"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_margin="15dp"
android:layout_above="@id/bottom_navigation"
android:src="@drawable/ic_add_white_24dp"
app:fabSize="normal" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
我的期望:
我得到了什么:
我能做些什么来改变这种情况?:D